From patchwork Fri Apr 5 15:32:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13619215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED342CD11C2 for ; Fri, 5 Apr 2024 15:32:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7FD0B6B0098; Fri, 5 Apr 2024 11:32:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 75E3E6B0099; Fri, 5 Apr 2024 11:32:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FD826B009A; Fri, 5 Apr 2024 11:32:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 43FCB6B0098 for ; Fri, 5 Apr 2024 11:32:40 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0CEA31A019A for ; Fri, 5 Apr 2024 15:32:40 +0000 (UTC) X-FDA: 81975870480.29.5872111 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 65B7A18002D for ; Fri, 5 Apr 2024 15:32:38 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=IGObMDuD; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712331158; a=rsa-sha256; cv=none; b=yWcULIJTzvhrL7VjwPyvpAu4n0Nto7K8JaxJHNqihIxrLF1giJKZGtcgCw01yJpKb6mVyO 5Z43n7dAb8qA6gbdWMcQWW1JHR6T5DFF47QYAn8vGTdaWtatAW0zGcm9GIPljrGFZczwEQ X5XAFz4ePGj+qPhv1S5dmfFBJQqJlt0= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=IGObMDuD; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712331158; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VeeeuX9ijoNo2EFoapFGaD6A7CnQ5h19HCUBd+GWV6w=; b=P/mYtDCp0XMiPIzZbUuUH+iR7FKZYyPbgqL6cqPxM4ubIvhNClYQVCAf87HxudxIxbQheB BcgIojUXaAx05s5lLO0rSeXsPlOwfu0RRHFx1UbTfjywaz8a33oqmra79Z4PmdIMFIXiZI gzSC7Fkf1b5Cm/N4MI5WEHUaoQMVnUw= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=VeeeuX9ijoNo2EFoapFGaD6A7CnQ5h19HCUBd+GWV6w=; b=IGObMDuD+uxNH20lXJhTwH7aHj eeOY4eHlDcSDO//66+lmun4Y4s5Mnq7DzU/c5JlYn38gLzAhNQ1bd2nAr9XVYbwH807okV/yHJDRa dQWNxnUl1UTsdH1H5eGiob6jF/E1ocy9JsIU5cGGGRLorQzdi/9aL+Wj/8FC+uAFk+E/9bampXUz+ mSaTg0y80ZLkpoxDhMJSKBTKPYmm2+e4zY2f9HXfNuxz6hsH0/yEp1MCxoHqSmLMvUi63B2Re6991 3TU/xK6bocGEee3l7fdPyGbqpktmpCwoHOK7ZpSQ+MPhFuHuNBKS9h/k7v/IBwTeAcunLIb+nnK2c 5hA/UT2Q==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rslYM-0000000AkxB-06vu; Fri, 05 Apr 2024 15:32:30 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 1/5] mm: Free non-hugetlb large folios in a batch Date: Fri, 5 Apr 2024 16:32:23 +0100 Message-ID: <20240405153228.2563754-2-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405153228.2563754-1-willy@infradead.org> References: <20240405153228.2563754-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 65B7A18002D X-Stat-Signature: 61gckdp9cigt6einbcicf4supwpqa5sb X-Rspam-User: X-HE-Tag: 1712331158-645147 X-HE-Meta: U2FsdGVkX19Fm6XjeVvdMUZ78eJ0/p2YQ02qNwWAav/Z2+VQNoSQc2C164WUL+pGWR3VMIc6W9mnkcrDWhdS83mKFe62nuEUXn94yFhh3ybrmZDYq30v4PwaQ4xmC/M5LavbQvWDgu+ZlZUV4VyKyq3hfbYe1ABXkQ2/+ZtrHErqNxP1FP0rNygsZiZlf2D3TxADwzqYp9Nc0Sla45rek4/R11wfXFcwWiuqPo9X/17ULErvxXqrv6l7H2ODwYXEGeVnGUPpXD7+fcqKj6/G8Mpmme5a7fJ4reth/d84gpHBbGL8TnCdDUOng93hBeL/Ybagapm7d6Zvk30YFwIsNP9pAcaerpQUtXPjRT1mdiE0ao5psJlALON5DY5IBF2w3W5/EzeomGs4NXzuc5tiP1QqRB4CJXZdS6yb0+TByCaFClK/p0NAPtUbYi9FIlBxUa4WpDdmDRPvhXPRhEgZp9u1Kud/Yi39kn6IR1qFsQjYjz8wnS2OCx9wJtgiuwyLkwnWs+0ErhK4mTq8jXLAsgpyeb85x2FQlncamDH+8q2S67hQxkJ8y53s5HA/wVtE65xfOq9AkN6giLgNVuAgEpDK/9Mrci8IBdXj/anxmRuPXdEQ5N/6ldR7mMK0Wcn3S2RRCb/4Nx51m5I2Fv3d8pvWdnm0wX2Dwhon/ubJfSDRE7+ZXvClO6i9jjJnEHZ1bjSHOxogxmOqeLh8C/iIkBwqTqG2noxAevuF2xDMsVfTo2FGgKSl+DcmspjPpRffS/Cmo8aXkPrVFyrx1I5A/YggEU07FApy4CmxHGopNjIfYwu4QJJGRwtmNUVbcwBFxn1jvn+9M8EiB5Dd3gnLnZIWy0xNt9MDO8hX4xclXt8s0YW77j3+fBx0XVDEe7uv1d9AuB7QXenqrFXNtOBnzPGOiw/DxcJadfdyfiGgrXQKFz+dTwPEZ3p6MpY8y8MAGfswUWp2I1y68aDembR oGSevdq/ AY+V+ipOUOZEh1g7gjUmFfnwtMK8vTRATMmNSfWY52Nw69qzZhsPcRdJCJsZRgrMSITbXnRRrr8kUzmI0hMDNxkPZt6KlK0rkPzeg9sQJJ12JO8uJHBncrtJGqwxm87E/ZpWUKOkcH9BOoV8Tm+Hnx560EM+tcOoemP1Dke2ykwTPW+uJSvvQ/n1trg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: free_unref_folios() can now handle non-hugetlb large folios, so keep normal large folios in the batch. hugetlb folios still need to be handled specially. I believe that folios freed using put_pages_list() cannot be accounted to a memcg (or the small folios would trip the "page still charged to cgroup" warning), but put an assertion in to check that. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Matthew Wilcox (Oracle) --- mm/swap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index f72364e92d5f..4643e0d53124 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -158,10 +158,11 @@ void put_pages_list(struct list_head *pages) list_for_each_entry_safe(folio, next, pages, lru) { if (!folio_put_testzero(folio)) continue; - if (folio_test_large(folio)) { - __folio_put_large(folio); + if (folio_test_hugetlb(folio)) { + free_huge_folio(folio); continue; } + VM_BUG_ON_FOLIO(folio_memcg(folio), folio); /* LRU flag must be clear because it's passed using the lru */ if (folio_batch_add(&fbatch, folio) > 0) continue;