Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1887822iob; Thu, 5 May 2022 10:07:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynor81GU+3xJO8DWmwSQEaJWMMUuI/7x2ZuXT4A+ee/dugfhX534X5OohYYrozMZSit5uL X-Received: by 2002:a05:6638:d16:b0:323:63cd:c144 with SMTP id q22-20020a0566380d1600b0032363cdc144mr12113643jaj.76.1651770463918; Thu, 05 May 2022 10:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651770463; cv=none; d=google.com; s=arc-20160816; b=dJ/joSdteBAJRhiB8N5uXpCEERJ4KcKpESxmxC4uya2jAIHOAxcZsHNwCyw6TEAZwL Js9BTDAmOMxfiOqzG4bSi3duVACF8vdH78RYWRfQ6wRkBohdLfWwF3rPHCliJ/5nWc6N FOIq19mv+aUWJTwj4xg0ZfSCPSl69Re8QwDdwFKc7tht98IUkjbac+WHThIWtkvuU5a9 jQusji+WCKK2+Ve8zmLIP4l9EtyFTQv3BnG3DVLDblN4dRnvgwjnnqGQJjdL7Z+WIlbQ UG+hflI15KT8qByc3sDO7apTcdkesENhyw5hxuE7cIb3MvYrU2ryVgKgDJXlm4VllW0F uxIA== 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:sender:dkim-signature; bh=IBbOZnTSEqAFzOW1mFDCOLOCAD06OzggQKmfl/tqan0=; b=v2DwL+rH3336TPnBWpDTU7vpLbntR/NMiaWZwUsGzAVjwXojPOqGptr4VVIN/tKrzh GnG0iDJP/UM8z1QQkvR5ZhXnkJnAocFFaNvB5FXCfTNRnogMhIAY/+WVWoGzwlnwM1cR YeylhqC250wek/kmGTsWgwh7RgiJeQKM7jSa3k93oSwqKyhG6IA21iL9rnj3tm5Q9F2E IRUDeStXL6tjkb2WC3NZX+4OD9zZjNA1FGBrNyubJUlcc9rWxbCP8VXRTWzTUMIF0mua PWZuL7yE1tgA1o2dQmamvceDF6z59AX1WgSBgPdicHY1oRfOz9DQ1x3M1xQSYaCGpmJx 0K7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZWAdYohJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l18-20020a92d8d2000000b002cc38bc4f2dsi1154111ilo.180.2022.05.05.10.07.24; Thu, 05 May 2022 10:07:43 -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=@gmail.com header.s=20210112 header.b=ZWAdYohJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233237AbiEEGOr (ORCPT + 99 others); Thu, 5 May 2022 02:14:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230304AbiEEGOq (ORCPT ); Thu, 5 May 2022 02:14:46 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 702C146654 for ; Wed, 4 May 2022 23:11:07 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id k1so3488747pll.4 for ; Wed, 04 May 2022 23:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=IBbOZnTSEqAFzOW1mFDCOLOCAD06OzggQKmfl/tqan0=; b=ZWAdYohJZEYZJYDIP8h0O3j0RbhgrCZO8fu8ng+dhXIT8lmC5eNuOXl6Vakk6G1jz3 tPXkormoNX3cF02GUARXqFJT9Bdkq7qHKnNFskzhDel4Dn7zntpVuVEzMUSIlhgLBsTs G9yLeMdvdHl/R0V0e4q0PdrvAcB7BZ4QMYBgtPE4XZQjs4KEK4ZA/HQ54Ru99PXnI9Ru 6fxDrrKntknLkcf17zd4O2/QFys9y66xJVP2TYZ/IRz+QDtungHVesTYCDOJIfOM2ala ibIHKCBNnKmXb8RxjieM3BXPaxlmkJspdNN/tk/YlVX+6/tlsRsvuLekuy5bwKZ+vey4 3x/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=IBbOZnTSEqAFzOW1mFDCOLOCAD06OzggQKmfl/tqan0=; b=LbRGxUsABynkVCIirqwLkH5Np0fsjzsAAlkVqsO9SQpOoy41qyMTEjG41/YwLaR0tH Nv1GywxP0ySbZHUsn0cYunqOT3EBs08iQkRUsP9rZsGJ/iCjU2xIIpJMcypczavQRGNb DGTl9srOZ0gY0tGv3luk6Gaml9EWe+Q7dx04LFdHYzjYyR8JWeqKdvRzR1bDDX0LP+XR EULixK7CP+ZfSwy+a66uQoHLabW1/khso9fFKdknhyoBwQccE17+g4OSbgWL69dGYSFC 4GZeZ998S00Nm7daFFsK0JUbH7jpDa/4MpT0/LZwoodJ3p+QKD60eYjz16Ptq3UAC/Z3 /cwA== X-Gm-Message-State: AOAM530HSilMJvl2NrXsXIcpP1m/zApNk8dc0uixVBTpSy/zkRFMXhNA KrLuq7Xk0MvIybsK3LrOoLU= X-Received: by 2002:a17:90b:3ecd:b0:1dc:94f2:1bc0 with SMTP id rm13-20020a17090b3ecd00b001dc94f21bc0mr4232087pjb.32.1651731066924; Wed, 04 May 2022 23:11:06 -0700 (PDT) Received: from google.com ([2620:15c:211:201:8435:b3e7:62fc:4dfa]) by smtp.gmail.com with ESMTPSA id bb6-20020a170902bc8600b0015e8d4eb2besm546170plb.264.2022.05.04.23.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 May 2022 23:11:06 -0700 (PDT) Sender: Minchan Kim Date: Wed, 4 May 2022 23:11:04 -0700 From: Minchan Kim To: Matthew Wilcox Cc: Andrew Morton , LKML , linux-mm , Suren Baghdasaryan , Michal Hocko , John Dias , Tim Murray , Vladimir Davydov Subject: Re: [PATCH] mm: don't be stuck to rmap lock on reclaim path Message-ID: References: <20220503170341.1413961-1-minchan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Thu, May 05, 2022 at 01:42:17AM +0100, Matthew Wilcox wrote: > On Wed, May 04, 2022 at 04:47:51PM -0700, Minchan Kim wrote: > > Since this patch introduces a new "contended" field as out param > > in rmap_walk_control, it's not immutable any longer so remove > > const keywords on rmap related functions. Since rmap walking > > is already expensive operation, I doubt the const would help sizable > > benefit(And we didn't have it until 5.17). > > Um? If it's now mutable, it surely can't be static as that means it > would be shared by all callers, and you might write to the new fields > in one caller and have them interpreted by the other caller! > > Or if it is safe, then the comment needs to not be deleted, but modified > to explain why it's safe to do so in this instance, and that other > instances should not copy the approach unless they are similarly safe. It's safe since rwc.contended is used only when rwc.try_lock is true. > > > diff --git a/mm/page_idle.c b/mm/page_idle.c > > index fc0435abf909..fdff8c6dcd2d 100644 > > --- a/mm/page_idle.c > > +++ b/mm/page_idle.c > > @@ -86,11 +86,8 @@ static bool page_idle_clear_pte_refs_one(struct folio *folio, > > static void page_idle_clear_pte_refs(struct page *page) > > { > > struct folio *folio = page_folio(page); > > - /* > > - * Since rwc.arg is unused, rwc is effectively immutable, so we > > - * can make it static const to save some cycles and stack. > > - */ > > - static const struct rmap_walk_control rwc = { > > + > > + static struct rmap_walk_control rwc = { > > .rmap_one = page_idle_clear_pte_refs_one, > > .anon_lock = folio_lock_anon_vma_read, > > }; So, delta is diff --git a/mm/page_idle.c b/mm/page_idle.c index fdff8c6dcd2d..bc08332a609c 100644 --- a/mm/page_idle.c +++ b/mm/page_idle.c @@ -87,6 +87,10 @@ static void page_idle_clear_pte_refs(struct page *page) { struct folio *folio = page_folio(page); + /* + * Since rwc.try_lock is unused, rwc is effectively immutable, so we + * can make it static to save some cycles and stack. + */ static struct rmap_walk_control rwc = { .rmap_one = page_idle_clear_pte_refs_one, .anon_lock = folio_lock_anon_vma_read,