From nobody Sat Dec 11 21:39:18 2021 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1CE0918CA3A5 for ; Sat, 11 Dec 2021 21:39:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JBLkt5rs0z3Dk5 for ; Sat, 11 Dec 2021 21:39:18 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A50BE1580E for ; Sat, 11 Dec 2021 21:39:18 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 1BBLdIcs099249 for ; Sat, 11 Dec 2021 21:39:18 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 1BBLdI42099248 for bugs@FreeBSD.org; Sat, 11 Dec 2021 21:39:18 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 260347] after kldunload memory allocated by the module stays wired Date: Sat, 11 Dec 2021 21:39:18 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 13.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: martin@bxlr.sk X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639258758; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=U2T4PQfFaEYzzwnyBJ7AHHDrji8NFR+1+IBqmVA5lhM=; b=v9z653Q7eCQtO4uB1JnOfIpu3KT1VmSV8sPnX21S8daXzmpwUGekDoJYbkE8RDNcQ1PK+l 6g0TsI0A03ySDKNaLy3SQ+yHwNHnBQjpS70qGKWKfAg7zdi6JGreMMgV6OnEE6dckrgLaa OJvbE9lZRo08TFuPCeafeJqCNsk8Z+aieZX3XMrgqA4mAxaIj2jEgn7wDrFgy4ab/eWrXX 0lEHDnnNm2RWTHt+E27pzh+Gw5xkmv2f78lsR1bDjHD5NYfXpab/Qs71p6ju5rk5HeXHma RWYxLkGi3ppE67VJ96bEKxTSqAkZLU36/Kkbhqynru14ILOWzWSu3+TIV42vtQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639258758; a=rsa-sha256; cv=none; b=bF7zOqmIrV4Y4JxobgrqOqLYpuG5SWM2wmItU9yBJydIKBU7JIvDFASV25Vp6MVHbPaWCj xODu+rC+SV4rTwMh30s8L8udxSTPRzqeqZ0Oda8BGDg8CztIrGZiix0bbKsmuLlgg3wPq7 NScYDceT8dzADTCaoCTGT9ruc2CuKD70piOtrKpk4HgPl5Ltf6nOeO+nvWZeod1dWxqj2w w8YJtHugDQGGfy+jc/VcUd3I+cVyDoVyr8EdCy5daApC22GiNLFhty8tHsnBkNksmVpRFk yUDn8KYA1SuxlWxUZNv1uRhf7ZASbtEgVM7xzGOOlC6d235OJaLXu8mUCgQ/vQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260347 Bug ID: 260347 Summary: after kldunload memory allocated by the module stays wired Product: Base System Version: 13.0-RELEASE Hardware: amd64 OS: Any Status: New Severity: Affects Many People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: martin@bxlr.sk I have a very simple kernel module, textbook example, that uses static buff= er. It seems memory stays wired even if module is unloaded. If I do it enough t= imes system runs out of memory. Not reproducible on FreeBSD 12.2 amd64. I'm opening the PR based on the forums discussion: https://forums.freebsd.org/threads/kldunload-failed-to-release-memory.83286/ I don't agree with the replies there (mine are _martin); if I'm mistaken I apologies for wasting everybody's time (and will rethink opening PR in the future). Simple kernel module: /* * KLD Skeleton * Inspired by Andrew Reiter's Daemonnews article */ #include #include #include /* uprintf */ #include #include /* defines used in kernel.h */ #include /* types used in module initialization */ #define BUFFER_SIZE 10*1000*1024 // 10 MB static char gBuffer[BUFFER_SIZE]; static int demo_init (void) { for (int i=3D0; i I compile the module and test it with the loop: sh while true ; do kldload ./test.ko && kldunload ./test.ko ; done In the other terminal I watch the memory utilization with top. Wired memory increases to the point where system freezes. OOM killer kills processes and system is available after a while. If I relaunch the top again I see wired memory is still almost all used, as if module leaves memory leak.=20 This behavior is not reproducible on FreeBSD 12.2 as I mentioned above. --=20 You are receiving this mail because: You are the assignee for the bug.=