Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp570296ioo; Thu, 26 May 2022 09:37:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPTI3xTc6zERJOa0EgWuBZKedTiEi0qooZBk+fb+aAwzVjd04KTQxCtiP3lULWadLGY0/C X-Received: by 2002:a17:907:7658:b0:6fe:8ee7:ca6 with SMTP id kj24-20020a170907765800b006fe8ee70ca6mr33912922ejc.205.1653583035472; Thu, 26 May 2022 09:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653583035; cv=none; d=google.com; s=arc-20160816; b=rzrU0yYx27MabbLph7tOUkwpf7qh88/vXRLAxcHYsFU6dr1TI+MF/wUzitCNjaCqU0 n+TD5uYWzkkSK6w0DdW+J/yeLA3P4HJVM3mFDFLziVUVbcqfb5N4mTm8xZjovT3z+jFg oT+zCaSnCFWyJUxsRTg+H0GOkDdG2IDsx5mWrxOnzYQ9Zt1c9Y269I3/l7b80b0iz7pd bxo38gK70vheWTcdVhG/l8tL6kY3o/M3wCkFXIx2DiWdmk0pskS3ISpYPL3QSQoD2/Xs p1gIdP/tb22pv9saqkz/VWk0/Cyj1Z8agcWLo+WGW4qoP2UGaHUbMKC+uUsFIngaKSvK YrIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+XvTKuREjiScrS3Wh3we/csDNgvvsNrhuVBevDa5cpg=; b=zOl+URy3VUmtYcxY4FkM0fmSzdqesOzPvdWIDQhbJKHe6KC8RX64tl8TVIxYMrQrgZ IQaLvyRSTHD67CNv7NGSi8XmFZlk2jXY6j+1GLDWP+t4cm6bi1BjrwXJlJfkAAgJT8i+ eu+abcetWpmGBht66mSEfaGECVQwgHXYxwTWuJmlYUX5MdbptGcQspZT/x/+y/WqnD68 FvGQMuuVbkdxs4WabR0ISX9X/RuXmG6pOt2phPKBW1EO725RCv7e2XizbMWrqVn07g42 WX+eUriAk/aJdI435beHYOqNV/ju1uYtXBTNYM4Z3RSZsJ6q9OVCLbGIqKOk6Ng5p4Rt b0kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=fVm+KR5u; 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=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o2-20020a056402438200b0042b3cf57cc9si2603313edc.71.2022.05.26.09.36.48; Thu, 26 May 2022 09:37:15 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=fVm+KR5u; 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=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234329AbiEYLi7 (ORCPT + 99 others); Wed, 25 May 2022 07:38:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230476AbiEYLi5 (ORCPT ); Wed, 25 May 2022 07:38:57 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 147EC9EB5F for ; Wed, 25 May 2022 04:38:55 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id s68so2385836pgs.10 for ; Wed, 25 May 2022 04:38:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+XvTKuREjiScrS3Wh3we/csDNgvvsNrhuVBevDa5cpg=; b=fVm+KR5uG2kq3XNouhS2R/L94OvDDTU5coc7ipX7iW9rngv/ZEpY3fR7NHUagopxnq NOwZb9CkIdXE0nJjQCctq7BtxhLQ5RH5UDgwn7ez4SWe2+R/yap0p0jr7yj17acjt5hw G2PZoTAJr6pA91fcCSfWMXpeVKvzq6Pj2WOXEWXqJDxveE9fTloLLW0HvKPKCRpfOOvj kTsCQO3/q12cvQi9bx61yDyTEow8FG97UUPM/VzTxV7mxBmQY4NlM1Qjv6zJQds3Twro mlhbxszL5yozEO+IH9fK94imsjOF7jy+Dv2HjJPKoYorkW96w95P6s8sUB0SsP3o98AX 0syw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+XvTKuREjiScrS3Wh3we/csDNgvvsNrhuVBevDa5cpg=; b=LeihjnmNTkYE0fJ5k0TZFkIEuqqkia0e6M3BT1FN8aa+zBS+rWXXkEuzxke/cTGc5E BKPAmACGxQ9xP18aSEbN2+i2gizCRPQYq5eVvMcaANZ0os9gsQUrv/bB+uda2o3L2sFN LvuUCYAk1A8rRI05bYipTlBXlYST+FZgjkoyrV5dSJpru9WmCepla7SBdODg03TTtFNr JwXqqzQTl3FhqVCSodcwFHo3//ap8ITYaYZw1sZrMCV2JSJrranJsgYtpsgT3Fkwcx6e d7mTYxOix9Pv3oWVvqvZjkt181tP9s4tVOBomHuIxMDg7xQLXv8/gN1tWKnto9O24ife 8zAA== X-Gm-Message-State: AOAM531mlyCArcwuTgqMXv6oAKC4YhxPqK3+b9awXZAwjvjxL5ALiTps ri0lnwqTmw5KpkTBjndncNv0nw== X-Received: by 2002:a63:9142:0:b0:3fa:dc58:8726 with SMTP id l63-20020a639142000000b003fadc588726mr2648562pge.349.1653478734613; Wed, 25 May 2022 04:38:54 -0700 (PDT) Received: from localhost ([2408:8207:18da:2310:c40f:7b5:4fa8:df3f]) by smtp.gmail.com with ESMTPSA id c27-20020aa7953b000000b0050dc762814fsm11277985pfp.41.2022.05.25.04.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 04:38:53 -0700 (PDT) Date: Wed, 25 May 2022 19:38:49 +0800 From: Muchun Song To: Johannes Weiner Cc: mhocko@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, longman@redhat.com Subject: Re: [PATCH v4 04/11] mm: vmscan: rework move_pages_to_lru() Message-ID: References: <20220524060551.80037-1-songmuchun@bytedance.com> <20220524060551.80037-5-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 On Tue, May 24, 2022 at 03:38:50PM -0400, Johannes Weiner wrote: > On Tue, May 24, 2022 at 02:05:44PM +0800, Muchun Song wrote: > > In the later patch, we will reparent the LRU pages. The pages moved to > > appropriate LRU list can be reparented during the process of the > > move_pages_to_lru(). So holding a lruvec lock by the caller is wrong, we > > should use the more general interface of folio_lruvec_relock_irq() to > > acquire the correct lruvec lock. > > > > Signed-off-by: Muchun Song > > --- > > mm/vmscan.c | 49 +++++++++++++++++++++++++------------------------ > > 1 file changed, 25 insertions(+), 24 deletions(-) > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 1678802e03e7..761d5e0dd78d 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -2230,23 +2230,28 @@ static int too_many_isolated(struct pglist_data *pgdat, int file, > > * move_pages_to_lru() moves pages from private @list to appropriate LRU list. > > * On return, @list is reused as a list of pages to be freed by the caller. > > * > > - * Returns the number of pages moved to the given lruvec. > > + * Returns the number of pages moved to the appropriate LRU list. > > + * > > + * Note: The caller must not hold any lruvec lock. > > */ > > -static unsigned int move_pages_to_lru(struct lruvec *lruvec, > > - struct list_head *list) > > +static unsigned int move_pages_to_lru(struct list_head *list) > > { > > - int nr_pages, nr_moved = 0; > > + int nr_moved = 0; > > + struct lruvec *lruvec = NULL; > > LIST_HEAD(pages_to_free); > > - struct page *page; > > > > while (!list_empty(list)) { > > - page = lru_to_page(list); > > + int nr_pages; > > + struct folio *folio = lru_to_folio(list); > > + struct page *page = &folio->page; > > + > > + lruvec = folio_lruvec_relock_irq(folio, lruvec); > > VM_BUG_ON_PAGE(PageLRU(page), page); > > list_del(&page->lru); > > if (unlikely(!page_evictable(page))) { > > - spin_unlock_irq(&lruvec->lru_lock); > > + unlock_page_lruvec_irq(lruvec); > > Better to stick with the opencoded unlock. It matches a bit better > with the locking function, compared to locking folio and unlocking > page... > Seems like we are missing folio unlock variants. How about intriducing folio_lruvec_unlock() variants? There are a lot of places where locking folio and unlocking page. Thanks. > Aside from that, this looks good: > > Acked-by: Johannes Weiner > Thanks.