Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4009697ioo; Wed, 25 May 2022 12:45:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwztQW1JLkcBvJUGC6GpIKPp2IYwwRzDd7xLQJ0bv3O2QwR+CKzxmlchZTR1sJcVlRc4Sya X-Received: by 2002:a17:90b:3b4c:b0:1e0:2c34:fbe8 with SMTP id ot12-20020a17090b3b4c00b001e02c34fbe8mr12271412pjb.70.1653507955566; Wed, 25 May 2022 12:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653507955; cv=none; d=google.com; s=arc-20160816; b=S7pNyl2AFA7PYNjXERpZGcp4yQkn2GvTHfPgiNiGG58GAKdFL8vyHxcnYIJO2qyxc2 Z30/DOmIRTqb78I2CuKLZJjrZVzn6cSPhJO9AQabZltLZYIY06qNB9MntHH0RF1nKkVS Bp+ShwALXLEssgrMPHyM04Fa8INQQyDUutV24KEEfFm4552MQ+6RBr6Ptzu76If5ld9u rX1qaKFc6sOfRVydqPv/2aKJhgG24/hqSKkS+ZRERnUXDPvazUGoe8J/TvnP/TQWpQeA 5kwe8ytFonPMlKoOfx9wTwQy/IibyxGOV3a+ewyl1Fumx2u9o4i+nx+y7TxYCIhTyjGX FZzg== 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=83P9lIf96SgEF4FIz+2NIYTMoqq/3LIlBOcpNeCCdxU=; b=kY5Q6j+7+iTE7bSgfBONRsv/H+8TM2t5UgyDSpSCdBt5IwP79dHb2boNmJbr9DKmy+ zfXcV98jmCV6hpq55DA5ZvHSqR7FZSfriSsJ13BbYXtirdrs9HkREeOB+UPI//NyVOoz Bzwk8LbijvWbUi2cAXtpcZqp2BYSFkEdC03wr+KUcm1xagn7a6n8ZB5JYK2O3NYcUeox EHA6T0BpovvqSCaHDpnM6xHONg2WnuzCV74Hs+6mB5aqig0LTFGyERMvr06Q3fvdc2so 4u1eo8TI0oXkcRRlWbK4RmQ981OIrUb6NAUm53n0Lozfunh65EybUpXL4Nfpb1wQt6TA cm7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="V9H/HXtZ"; 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 h13-20020a056a001a4d00b0050a72d68775si24778449pfv.28.2022.05.25.12.45.43; Wed, 25 May 2022 12:45:55 -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="V9H/HXtZ"; 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 S229828AbiEYL6a (ORCPT + 99 others); Wed, 25 May 2022 07:58:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbiEYL62 (ORCPT ); Wed, 25 May 2022 07:58:28 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C373C65CE for ; Wed, 25 May 2022 04:58:23 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id b135so7279368pfb.12 for ; Wed, 25 May 2022 04:58:23 -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=83P9lIf96SgEF4FIz+2NIYTMoqq/3LIlBOcpNeCCdxU=; b=V9H/HXtZcLAXr098dtpBDsWTnNouWEfreWbUot8dXiLuBzVLB4mCHrI6WKX6pVyZBD kiNUVaM5D5ayScwD40y9Txc6lXPYaCgigth5ZN7Ae3+g2nfLeqXrNFEtKPGXdutjjO3n XhABixH/23MX1UYyLqe8AiN6xxOLpLYfmjfZzE4eMmEaIK+3FtTAdD/h92PM9AcDNnvv l3sS52cpVjTlm0KWQFUHr4gAgMldcOrjQLPJSBo5dCH5wXpwJDUCn8jjooO4sCA/4QAp wZktZJWFJjkaF/4ebJ6wXuCrOZYssWMh3qoqUYyRbVykBTT1PCykeNLMxk3ucGph1lD3 Oa0Q== 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=83P9lIf96SgEF4FIz+2NIYTMoqq/3LIlBOcpNeCCdxU=; b=PrM3rAUxhOzoED3i/O6jQspdbY2Jhjvupqqh3o+alzp6ScBgyiWwk66fPfGukS2eSo L/j13Sc/xGGoXyXj9ezxVzuFOy+6mdWxXX7sIa41ehTK9rD7iiHl7hBS5tmmfV7WL8mO 0LanCrRuFDO/T38ISB+UfXcw7V7NYUPluUkutBo8XWJZdpYV5Sy5tNvmuCB2oJhUspMB Zo51el4GAgV3BVIxRF8nhK0P0wJNis71gUlolV56ql04z1J73Pic0rLYRCSc0vKEDeIx iE1IFLzP6W/JfrhkzWYL3Lk+Ktv0wpFSTQQFnV4gndWDBJ6W6mg+WN5ERypW8wjr2/7R CSzQ== X-Gm-Message-State: AOAM531noDc3TjFpCVLYkWdRM7O4q2RE1oZsBAGjnzLqAspjwwmgMK6P YNtpKIwwfQtAzF2dvtAM1mMkAA== X-Received: by 2002:a62:14d2:0:b0:518:1576:65f2 with SMTP id 201-20020a6214d2000000b00518157665f2mr33285530pfu.24.1653479903310; Wed, 25 May 2022 04:58:23 -0700 (PDT) Received: from localhost ([2408:8207:18da:2310:c40f:7b5:4fa8:df3f]) by smtp.gmail.com with ESMTPSA id e24-20020a637458000000b003f5e0c264bcsm8276248pgn.66.2022.05.25.04.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 04:58:22 -0700 (PDT) Date: Wed, 25 May 2022 19:58:16 +0800 From: Muchun Song To: Roman Gushchin Cc: hannes@cmpxchg.org, mhocko@kernel.org, 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 10/11] mm: lru: add VM_BUG_ON_FOLIO to lru maintenance function Message-ID: References: <20220524060551.80037-1-songmuchun@bytedance.com> <20220524060551.80037-11-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 07:40:05PM -0700, Roman Gushchin wrote: > On Tue, May 24, 2022 at 02:05:50PM +0800, Muchun Song wrote: > > We need to make sure that the page is deleted from or added to the > > correct lruvec list. So add a VM_BUG_ON_FOLIO() to catch invalid > > users. > > > > Signed-off-by: Muchun Song > > --- > > include/linux/mm_inline.h | 6 ++++++ > > mm/vmscan.c | 1 - > > 2 files changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h > > index ac32125745ab..30d2393da613 100644 > > --- a/include/linux/mm_inline.h > > +++ b/include/linux/mm_inline.h > > @@ -97,6 +97,8 @@ void lruvec_add_folio(struct lruvec *lruvec, struct folio *folio) > > { > > enum lru_list lru = folio_lru_list(folio); > > > > + VM_BUG_ON_FOLIO(!folio_matches_lruvec(folio, lruvec), folio); > > + > > update_lru_size(lruvec, lru, folio_zonenum(folio), > > folio_nr_pages(folio)); > > if (lru != LRU_UNEVICTABLE) > > @@ -114,6 +116,8 @@ void lruvec_add_folio_tail(struct lruvec *lruvec, struct folio *folio) > > { > > enum lru_list lru = folio_lru_list(folio); > > > > + VM_BUG_ON_FOLIO(!folio_matches_lruvec(folio, lruvec), folio); > > + > > update_lru_size(lruvec, lru, folio_zonenum(folio), > > folio_nr_pages(folio)); > > /* This is not expected to be used on LRU_UNEVICTABLE */ > > @@ -131,6 +135,8 @@ void lruvec_del_folio(struct lruvec *lruvec, struct folio *folio) > > { > > enum lru_list lru = folio_lru_list(folio); > > > > + VM_BUG_ON_FOLIO(!folio_matches_lruvec(folio, lruvec), folio); > > + > > if (lru != LRU_UNEVICTABLE) > > list_del(&folio->lru); > > update_lru_size(lruvec, lru, folio_zonenum(folio), > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 761d5e0dd78d..6c9e2eafc8f9 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -2281,7 +2281,6 @@ static unsigned int move_pages_to_lru(struct list_head *list) > > continue; > > } > > > > - VM_BUG_ON_PAGE(!folio_matches_lruvec(folio, lruvec), page); > > The commit log describes well why we need to add new BUG_ON's. Please, add > something on why this is removed. > OK. Will do in v5. Thanks.