From mboxrd@z Thu Jan 1 00:00:00 1970 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 6AEADC433FE for ; Tue, 24 May 2022 19:38:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1C848D0003; Tue, 24 May 2022 15:38:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ECB2F8D0002; Tue, 24 May 2022 15:38:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB5238D0003; Tue, 24 May 2022 15:38:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C8BFB8D0002 for ; Tue, 24 May 2022 15:38:54 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9F44460A5B for ; Tue, 24 May 2022 19:38:54 +0000 (UTC) X-FDA: 79501649388.27.949BE54 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by imf17.hostedemail.com (Postfix) with ESMTP id 84FD340025 for ; Tue, 24 May 2022 19:38:24 +0000 (UTC) Received: by mail-qk1-f171.google.com with SMTP id c1so15809073qkf.13 for ; Tue, 24 May 2022 12:38:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=OnMNwdiDuKNvcNvHgJhe6ilL5BSVkcDVAFFW/UQvNfs=; b=pSUp9QP4W736sqLANtAdsbjcRxz7NxrgIsEjTxS91pMbK6MTlMhrm614GZKG+ZIZbh iy9WT5WKW0//Z4XyhuoEObIzJK7/VSRFbhHydJajpTdSneWWzCXiZ+Qd92OzgcqAjq/B DgRjbCbFqtxfsgTgZLqSu5BOxuSvCQVg1SrGaDKURpJhCRAhkJm+k7oixIVzT3lJdFlx oTz3WPP00s/i7i+MIM5I+ZU01FbelOHQX9riGe2P9gCaRTQ0imjJ4ZWrUAmXI6xOYg56 w43gFLQ9qfZxe34KG9XEHzI7kFN5BbtFfjsEea8+I/OaP6R5fmeQM7sMVnflF1nol3iw cwcA== 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=OnMNwdiDuKNvcNvHgJhe6ilL5BSVkcDVAFFW/UQvNfs=; b=b3oG6m3hQuOSHR9SheJGL6kmUUUtqguUa+R2k3iJ5NtZEtaGSrDbRIlUdlUQG+U/OO KUU09pWQiJD75T00P3tj75O5bQwUue0XWUX0rT15eJNqqJbF7Yr96BjmJeW5qmFlrrbz 8QFb5TsC30zSNCG6ZkdyKtwTe0MTiU76gAxYD+rEYsizh1jVFwNJUUvYwcqe5y6d85pW G4fhs3AqImtB5v1guGsLtte8WGPO+OoLY1CoZrOiCyZ27uZNywnNf2U6Y0wnMNlkU8q1 0m7tB0txzbDaSwcWpjLj6R0+apUt87zLihBMdxynG05hOcjaIphUr9Oz+bXIvggrYKgC B34w== X-Gm-Message-State: AOAM530PCfW3V4yoWluZlw1KJScMoe/QS4Dq+TL1kietTbNNVOLwUG/R rXIhfpJBTisulDR5oZOqq9vZ7A== X-Google-Smtp-Source: ABdhPJzpIEt5iXGru2w27WyHG1PnabM7gE/0alg9o2icl4RBIq96dAtM8gIayTZ3UyzOh6zuMEmngg== X-Received: by 2002:a05:620a:2412:b0:6a0:5f8e:c050 with SMTP id d18-20020a05620a241200b006a05f8ec050mr18145974qkn.462.1653421131663; Tue, 24 May 2022 12:38:51 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:741f]) by smtp.gmail.com with ESMTPSA id o16-20020a05620a0d5000b006a33c895d25sm75913qkl.21.2022.05.24.12.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 12:38:51 -0700 (PDT) Date: Tue, 24 May 2022 15:38:50 -0400 From: Johannes Weiner To: Muchun Song 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: <20220524060551.80037-5-songmuchun@bytedance.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 84FD340025 X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=pSUp9QP4; spf=pass (imf17.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.171 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-Stat-Signature: eib6jweht9yqc7dqiowyqu8bmqz96tua X-HE-Tag: 1653421104-73023 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: 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... Aside from that, this looks good: Acked-by: Johannes Weiner