Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1683727rwl; Fri, 31 Mar 2023 15:13:48 -0700 (PDT) X-Google-Smtp-Source: AKy350YZJd1vh3BCeJT8roaripeGTKO2u+7hrrdTOf/V6vO83hfNANNLeZ4auX1v3Q3uepwdsNmz X-Received: by 2002:a17:906:224e:b0:92c:fc0:b229 with SMTP id 14-20020a170906224e00b0092c0fc0b229mr6710809ejr.0.1680300828226; Fri, 31 Mar 2023 15:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680300828; cv=none; d=google.com; s=arc-20160816; b=IYGR5WAll+fsD6h5aBPeD4dJ6pUr0ff82YqzQCBTWgwnIiwtmubdKgnrtDxihDNd3A Xiw4gkrenoarQY57ZMODkf1H1AnX5c7qsIXxrtCNCXzIujR44W4dfTUP3BxjxMRBCNuX zYfxVDDB9jlw5qj5LqTo9MdRzdKbosGLISjMIlmopTehswIKqQg/1b0dHTkqy2g9md8k bb4gNfWlNuunnbZGP45OcCmG8n7eubDWDK42s1j1Cg8PeHOM1jVEnEC3qEL3A3/aPYVj rbY8Qk/mD3hPf+wP2XflddfCKbCujKwZ7MRUtF94DLq7G01Mxkg9uLkA0vRd+9eSyEAs ssoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=sC9KN2RKkXadBsDx3V19qiDGy6Qklf9zIf+ThKaBq1s=; b=UuziRoTJGBtSmlQPN0hiaCbdDhYg5t999eTokMSm/fEPWXsRaBr8ZcuHqDCJBphWQd 2NfBS17Wogj9MAhZXTAR9E/k8OBu4sJVfIou8j5VtixyrNh0ZPK+L6l3DBXOdBG25Mv0 a/fPGnfYHpNMzi4w5wugBRC9EbgER8uZRkqfkrEt7ANAFiccA9Mog9oCOkvReLQhGqGJ 4N0QpSk3L7bmntC8+6Gp5xY72kqLNtNCh1sFTO07Nsc2b0CSW+1Q6a9/yxaWU+d56K4f UWOpjlufzPXKWOtG0Im3ml5wZHIm2q6rpTwPoS6EPfNI759NXHnHM5V8qfwujOPHPMso zRnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=vs6Lz4cA; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gj6-20020a170906e10600b008cf961a7be1si2935935ejb.830.2023.03.31.15.13.23; Fri, 31 Mar 2023 15:13:48 -0700 (PDT) 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; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=vs6Lz4cA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232917AbjCaWEe (ORCPT + 99 others); Fri, 31 Mar 2023 18:04:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229998AbjCaWEd (ORCPT ); Fri, 31 Mar 2023 18:04:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BB0A1FD3E for ; Fri, 31 Mar 2023 15:04:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E134562C22 for ; Fri, 31 Mar 2023 22:04:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F77FC433D2; Fri, 31 Mar 2023 22:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1680300271; bh=y75tzqtO/00AP4h3NcC3yhpaClgjp49viV/Jpgl25Gc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=vs6Lz4cAD8QohfCI437uO557Vnvq0b76OWFRvJsAKCHGygOsdzzGReFzksV2buL80 IHi8KOP1IFpIlRbVJrWEZuv3VitjFuV0Hj64kw1dokZLWh9Gq4bPOQ7hpjnCTQA382 ex71kxhcZ2X+w+BMMWP0+1G9c6+RY5vpRDAogG8I= Date: Fri, 31 Mar 2023 15:04:30 -0700 From: Andrew Morton To: Qi Zheng Cc: willy@infradead.org, lstoakes@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] mm: swap: use folio_batch_reinit() in folio_batch_move_lru() Message-Id: <20230331150430.546de954b0a7918f042c562e@linux-foundation.org> In-Reply-To: <20230331095858.51810-1-zhengqi.arch@bytedance.com> References: <20230331095858.51810-1-zhengqi.arch@bytedance.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 On Fri, 31 Mar 2023 17:58:57 +0800 Qi Zheng wrote: > In folio_batch_move_lru(), the folio_batch is not freshly > initialised, so it should call folio_batch_reinit() as > pagevec_lru_move_fn() did before. > > ... > > --- a/mm/swap.c > +++ b/mm/swap.c > @@ -222,7 +222,7 @@ static void folio_batch_move_lru(struct folio_batch *fbatch, move_fn_t move_fn) > if (lruvec) > unlock_page_lruvec_irqrestore(lruvec, flags); > folios_put(fbatch->folios, folio_batch_count(fbatch)); > - folio_batch_init(fbatch); > + folio_batch_reinit(fbatch); > } > > static void folio_batch_add_and_move(struct folio_batch *fbatch, Well... why? This could leave the kernel falsely thinking that the folio's pages have been drained from the per-cpu LRU addition magazines. Maybe that's desirable, maybe not, but I think this change needs much much more explanation describing why it is beneficial. folio_batch_reinit() seems to be a custom thing for the mlock code - perhaps it just shouldn't exist, and its operation should instead be open-coded in mlock_folio_batch(). The dynamics and rules around ->percpu_pvec_drained are a bit mysterious. A code comment which explains all of this would be useful.