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 B381DC433EF for ; Thu, 5 May 2022 06:11:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E638B6B0071; Thu, 5 May 2022 02:11:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E13306B0073; Thu, 5 May 2022 02:11:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D015A6B0074; Thu, 5 May 2022 02:11:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BF8376B0071 for ; Thu, 5 May 2022 02:11:08 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 93564210B3 for ; Thu, 5 May 2022 06:11:08 +0000 (UTC) X-FDA: 79430666616.10.A6C602C Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf07.hostedemail.com (Postfix) with ESMTP id B820B4007B for ; Thu, 5 May 2022 06:11:03 +0000 (UTC) Received: by mail-pl1-f171.google.com with SMTP id n18so3491693plg.5 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=bV7YoFHkerOv12gcJhhq8gGxge6xdkdMXnNTL3MZtJ9gCwyYvHoboH0UpUiuo6PFmN DwI6ynO2bKnWrV/W1eTxcNCxXuOZww9u8jvWASg8EDrVnkJbqrmKbeXK/DlHQWEc9RPY pKuEyMjozd8xxcGpRvNLrddHNfLzjIJTIplpPgHfweSohk/pv3+/LZW/ym03bavAn76d YJqAW5VSyPL5eEfa+6JBI7CURJMl74/gVjNVyk0gMFbZ0pY4oVvaWzwMyg7Gqi8zJOd9 Y982FtJgecd756mJX0P+E2rKEhM4UcVnRPywC3l+HUv3XHWXD51BWUyZjNMWt/6l4YTm 17fQ== X-Gm-Message-State: AOAM530PjNxAYHr5sWOy2p7UgkUm7Tj89eCkS/xocuNVnNd5i5YhFZua //uTkdnNui5/cfw+PYCfOyI= X-Google-Smtp-Source: ABdhPJyxPgNQtsnhXBAjSa/+0PBF5EszwI+PJ7RFR2HsWS4kXzHZrKX+q6rWHO4BgIUPF6PsAdvPtw== 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) 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-Stat-Signature: jsoff8rptj3e7nszahi5ct66kz6s4uoj X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B820B4007B Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ZWAdYohJ; spf=pass (imf07.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-Rspam-User: X-HE-Tag: 1651731063-542384 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000085, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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,