From patchwork Thu Dec 29 13:30:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yang X-Patchwork-Id: 37385 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2402496wrt; Thu, 29 Dec 2022 05:33:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXv+fYVPuo8TjsrqJqmrWPCxuLSsjdeNfL+gXObagrVFCZoaOqlr+Ukxq6RiEIJqXo0l6LV2 X-Received: by 2002:a05:6a00:15d5:b0:581:88a4:9180 with SMTP id o21-20020a056a0015d500b0058188a49180mr10620153pfu.22.1672320781394; Thu, 29 Dec 2022 05:33:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672320781; cv=none; d=google.com; s=arc-20160816; b=SGUUvpMXNrDTeE+JBPWn+bqfKUGt3ZlZ0xcxOnLXKbN3cjm03V+yinGaTjB5vEgyAM 8OOX+fj24lF04b5fqEEaIX70EDNzt7V+osR26rM+58ZVc7UWzjN9mCRnsEGipRTXkBpd exaZvKD3sLw46t7lMZxkC6zSJSnLOEc5oNVKTjL7MvpzD3GWD+mVAJIIpIR9PAKCca30 ZQoDFQwVj5//m0WG1tkbUG+jRb7wf1XiEj0LoB8nJhD2BeC8tBgemZ72dmbySiujntEI Uxijur1uFCBC+EcWp66XwYunnOFRbrhW/Jg0lnVplRGnUDv1jlQKzkAm1H/2bWTOZpgR zTyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=nhtfReyy3cvlBdPkEiUQcXfVc/YDn2DXVVEJGWtmltU=; b=ZPBg9FJNGvVcDlxxzQiZTbYhU9HLaOIpnVgwodHZu1rjhj5zSrVkBqKNd4QdsAXvMF QXzcn5BMpfYEKSfspcUMK/fhYZCnidz6nOfoHiVwRpy5j3z6EJT8aP17hux1clY2KlQM KEnNcaWVuteDC+lQEbBfCef4OcVgzdkippWacDVDDKz5Hq2TRyb7g65dQSmGUlVaqvDX 3fDs1Pql8ixJsq9NEE0Eon1uKHaGdKAlkDlPk+7p7zlqP8ZufNJeMZv0CGpJcLoieeY0 K92kHkYE+dkqAhvUbh4qy78KkhM3Y+L7axqMcBAsGrVFhGSNFBfIsJFj1uAxRGa1KOjd NgXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a056a0010d100b005808991ba14si18708944pfu.234.2022.12.29.05.32.48; Thu, 29 Dec 2022 05:33:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233187AbiL2NaR (ORCPT + 99 others); Thu, 29 Dec 2022 08:30:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbiL2NaP (ORCPT ); Thu, 29 Dec 2022 08:30:15 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53044FACF; Thu, 29 Dec 2022 05:30:11 -0800 (PST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4NjTlj0fLRz8R040; Thu, 29 Dec 2022 21:30:09 +0800 (CST) Received: from szxlzmapp04.zte.com.cn ([10.5.231.166]) by mse-fl1.zte.com.cn with SMTP id 2BTDTxbk062621; Thu, 29 Dec 2022 21:29:59 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Thu, 29 Dec 2022 21:30:03 +0800 (CST) Date: Thu, 29 Dec 2022 21:30:03 +0800 (CST) X-Zmail-TransId: 2b0363ad965bffffffff8efe8e3d X-Mailer: Zmail v1.0 Message-ID: <202212292130035747813@zte.com.cn> Mime-Version: 1.0 From: To: , Cc: , , , , , Subject: =?utf-8?q?=5BPATCH_linux-next=5D_swap=5Fstate=3A_update_shadow=5Fno?= =?utf-8?q?des_for_anonymous_page?= X-MAIL: mse-fl1.zte.com.cn 2BTDTxbk062621 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 63AD9661.000 by FangMail milter! X-FangMail-Envelope: 1672320609/4NjTlj0fLRz8R040/63AD9661.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63AD9661.000/4NjTlj0fLRz8R040 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753555435758312128?= X-GMAIL-MSGID: =?utf-8?q?1753555435758312128?= From: Yang Yang Shadow_nodes is for shadow nodes reclaiming of workingset handling, it is updated when page cache add or delete since long time ago workingset only supported page cache. But when workingset supports anonymous page detection[1], we missied updating shadow nodes for it. [1] commit aae466b0052e ("mm/swap: implement workingset detection for anonymous LRU") Signed-off-by: Yang Yang --- include/linux/xarray.h | 3 ++- mm/swap_state.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/xarray.h b/include/linux/xarray.h index 44dd6d6e01bc..cd2ccb09c596 100644 --- a/include/linux/xarray.h +++ b/include/linux/xarray.h @@ -1643,7 +1643,8 @@ static inline void xas_set_order(struct xa_state *xas, unsigned long index, * @update: Function to call when updating a node. * * The XArray can notify a caller after it has updated an xa_node. - * This is advanced functionality and is only needed by the page cache. + * This is advanced functionality and is only needed by the page cache + * and anonymous page. */ static inline void xas_set_update(struct xa_state *xas, xa_update_node_t update) { diff --git a/mm/swap_state.c b/mm/swap_state.c index cb9aaa00951d..ed7c652d06db 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -94,6 +94,8 @@ int add_to_swap_cache(struct folio *folio, swp_entry_t entry, unsigned long i, nr = folio_nr_pages(folio); void *old; + xas_set_update(&xas, workingset_update_node); + VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); VM_BUG_ON_FOLIO(folio_test_swapcache(folio), folio); VM_BUG_ON_FOLIO(!folio_test_swapbacked(folio), folio); @@ -145,6 +147,8 @@ void __delete_from_swap_cache(struct folio *folio, pgoff_t idx = swp_offset(entry); XA_STATE(xas, &address_space->i_pages, idx); + xas_set_update(&xas, workingset_update_node); + VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); VM_BUG_ON_FOLIO(!folio_test_swapcache(folio), folio); VM_BUG_ON_FOLIO(folio_test_writeback(folio), folio);