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 9AFFCC433EF for ; Thu, 5 May 2022 00:42:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08F5D6B0071; Wed, 4 May 2022 20:42:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 03E966B0073; Wed, 4 May 2022 20:42:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E48126B0074; Wed, 4 May 2022 20:42:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D64406B0071 for ; Wed, 4 May 2022 20:42:24 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id AA82B202EE for ; Thu, 5 May 2022 00:42:24 +0000 (UTC) X-FDA: 79429838208.01.AC1DC98 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id ACB8240087 for ; Thu, 5 May 2022 00:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=T7WIlBgKui0D1mjEUcKRlP2dzC8kLdnUcd6Fq6x/GF0=; b=N3kQHbKSAbBc2NOv/bkgKV6Z6d JZvcFXiUIyY9tAbssoBagG+2VxnscEZaZ+Ym2LfwqbEMO0FIqO2i5qYQFQczNEB/ukzFoZH0aXiah rbABlw4f2SV0ScO9wIYepG7a8PF/BxpnxXOZwEiXUz6EKmSy+XbVBsgTvONTLCqVz3/VU0BSOGMnf jXvTY2wUA7ciDsa7RIq80R6gzvFClpf14zwJzBORvdkBeWqRXFovogiZb2oGBaEx/11Oac190dVzV LM5yU7/APG4+mkxqqO9HVEnWcH+mdpbFWApQVeqBXfCHjXA+5yJYnVqVap62hL9xRabJIOTmbNGEP unamjuYQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmPZR-00H83f-Ks; Thu, 05 May 2022 00:42:17 +0000 Date: Thu, 5 May 2022 01:42:17 +0100 From: Matthew Wilcox To: Minchan Kim 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-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: ACB8240087 X-Stat-Signature: 11r5hxy7zd36zr69d66hkq67tmii69ju X-Rspam-User: Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=N3kQHbKS; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1651711339-786367 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000009, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. > 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, > };