From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.142 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795964973; b=ePl2YQV4Ofy94vp207CS9gaPKoylYTuC+2h6f3LrDCHlhVrwT4WH0Cm/WTgR4QNJwE6v UBQVhXaDK4s4vARElMpGUffQ+k7qw1Q8mfCqOJYtTk9NdwG+4fQcQaHsTGx8EercSoZb1 5zoHkS4JMr+Ipg7+4ciwC+GPSJPwu5c0KUXmBtbHMR3UofcPZ0lIj1KsRAbh2K8m2cH1i 0V5gnNtGVPkZgaXVIkel0/VykAOi3Z3C/aM/IsLkhmIBt64UQGlFeAp5t9GJ+yge2Z2Po pTWMwFfnmRb4WDDSmgwvz+Odt769mdGWGfdHLzaT8o12v//dfmkOlvO75AvwVX1EQew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795964973; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version:Content-type: Content-Transfer-Encoding; bh=WhTgDvSOWr3Bp4xIs0jtK+SShYYOetn3DS86Bbz9ksY=; b=AooWcKHwl8Jo0Z69uI1Zz9d01EvjNl36W5KTvscEd36Vja6TMuzwyovsqukDJttViTsR cPb1vgVCkMNJnGFXBzeYUAdAg03QNx4YGw45LlT8nCAqR7OGw+VMKWzcsrNPNPefQ/w4Q vgZIg7fwyELrV0/8nrDnZxmMkUOGTWp2yXF2ioSAUyj63IGjEYQTRD1cPHsM4YnRyYZm5 Hzci7YaYguDirCiWJjfXiCCpWuPOqykZgpDkfOjQscCFVrzIMc1l9vokyXCkIXGZUJ2ur 3yW7J2btA1G4OBQx8lM4iObmMDhDH7phJHpndoQOUGS6ZC4m5antn025Un+ky3c1GRg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=DCST2LWV; arc=none smtp.remote-ip=95.215.58.142 Received: from mta1.migadu.com (out-142.mta1.migadu.com [95.215.58.142]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E2AF606A325 for ; Sun, 29 Nov 2026 15:09:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8E2AF606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=DCST2LWV X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=AeroXwOiSnewwUBRqFMq6gBg0t/vzgxukveCT3NZEks=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1795964970; v=1; x=1796569770; b=DCST2LWVgv/MZfsu4rRu2z2CjksXQdU8lnnX7G2R9GEyAtm9GDrRwxSYKpURL5hTZNe8zO9O REzEQlemhLyfow1IfN81gqFoNog+9h/prc2IXMh/jRD+NW7GL9YIWh6FLhEKuu1hFOhkAI6uVLU OHc6JCHksHDJQ/Q6uPIOvlGo= X-Envelope-To: linux-kernel@vger.kernel.org Received: by mta10.migadu.com with ESMTPS id cd83ed35f59582bf; Sun, 29 Nov 2026 15:09:30 +0000 X-Mizu-Trace-ID: cd83ed35f59582bf X-Migadu-Flow: FLOW_OUT From: Baoquan He To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, david@kernel.org, chrisl@kernel.org, kasong@tencent.com, urezki@gmail.com, hannes@cmpxchg.org, corbet@lwn.net, nphamcs@gmail.com, baohua@kernel.org, youngjun.park@lge.com, shikemeng@huaweicloud.com, yosry@kernel.org, chengming.zhou@linux.dev, kunwu.chan@gmail.com, klarasmodin@gmail.com, linux-kernel@vger.kernel.org, baoquan.he@linux.dev, Baoquan He Subject: [PATCH v7 14/14] mm, swap: skip the overcommit probe when removing xswap Date: Sun, 29 Nov 2026 23:07:55 +0800 Message-ID: <20261129150755.191662-15-baoquan.he@linux.dev> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261129150755.191662-1-baoquan.he@linux.dev> References: <20261129150755.191662-1-baoquan.he@linux.dev> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit From: Baoquan He swap_info_remove() probes whether Committed_AS still fits under the commit limit left after the device's pages are subtracted. An xswap device's pages are its address space, not backing storage, but they raised the commit limit at creation. A workload can commit into that headroom, after which the probe refuses to destroy the device. Skip the probe for xswap until the overcommit accounting for it is settled. Real swap devices keep the existing protection. Signed-off-by: Baoquan He --- mm/swapfile.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 3a84dbd7a54c..c650db1e1159 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3667,10 +3667,17 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) */ static int swap_info_remove(struct swap_info_struct *p) { - if (!security_vm_enough_memory_mm(current->mm, p->pages)) - vm_unacct_memory(p->pages); - else - return -ENOMEM; + /* + * The device's pages are its address space, not backing storage. + * The commit limit it added may have been committed against, so + * skip the probe until the limit stops counting that space. + */ + if (!(p->flags & SWP_XSWAP)) { + if (!security_vm_enough_memory_mm(current->mm, p->pages)) + vm_unacct_memory(p->pages); + else + return -ENOMEM; + } spin_lock(&p->lock); del_from_avail_list(p, true); -- 2.54.0