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 X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DEF3C28CBC for ; Wed, 6 May 2020 23:36:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B44B420735 for ; Wed, 6 May 2020 23:36:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ui8uf+Ro" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B44B420735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2A5BF900003; Wed, 6 May 2020 19:36:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 25693900002; Wed, 6 May 2020 19:36:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16B2F900003; Wed, 6 May 2020 19:36:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id F092D900002 for ; Wed, 6 May 2020 19:36:21 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A08FB10F6D for ; Wed, 6 May 2020 23:36:21 +0000 (UTC) X-FDA: 76787905362.28.flock12_1a5a85b0d9836 X-HE-Tag: flock12_1a5a85b0d9836 X-Filterd-Recvd-Size: 4363 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 May 2020 23:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588808180; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4GE42jOdua+ii9NEsVA32zpvW4/j25e1V7wWknNFBjw=; b=Ui8uf+RoBzW6RV4R/+cC/kMGHVA7Ys2YbpkdP+PpeIaW+xm6flAS+RIeN7EcMddhq8ZUC4 jmrvg+hvj0KGwGHajGVWD9KruIf+/aYZDZqzEXi0SYgotk5qd887XZFbyYHZMsbOucpap9 lYYL3INYTBhAMgP5/xEBrQXODZJC504= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-479-P-BrVCLeOZmYGn3Rw1NMCA-1; Wed, 06 May 2020 19:36:18 -0400 X-MC-Unique: P-BrVCLeOZmYGn3Rw1NMCA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C60A1835B40; Wed, 6 May 2020 23:36:16 +0000 (UTC) Received: from optiplex-lnx (unknown [10.3.128.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C6C010013BD; Wed, 6 May 2020 23:36:14 +0000 (UTC) Date: Wed, 6 May 2020 19:36:11 -0400 From: Rafael Aquini To: Luis Chamberlain Cc: cl@linux.com, akpm@linux-foundation.org, arnd@arndb.de, willy@infradead.org, keescook@chromium.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: expland documentation over __read_mostly Message-ID: <20200506233611.GC205881@optiplex-lnx> References: <20200506231353.32451-1-mcgrof@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200506231353.32451-1-mcgrof@kernel.org> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 Wed, May 06, 2020 at 11:13:53PM +0000, Luis Chamberlain wrote: > __read_mostly can easily be misused by folks, its not meant for > just read-only data. There are performance reasons for using it, but > we also don't provide any guidance about its use. Provide a bit more > guidance over it use. s/it/its same goes for the subject, as I think there is a minor typo: s/expland/expand > > Acked-by: Christoph Lameter > Signed-off-by: Luis Chamberlain > --- > > I sent this 2 years ago, but it fell through the cracks. This time > I'm adding Andrew Morton now, the fix0r-of-falling-through-the-cracks. > > Resending as I just saw a patch which doesn't clearly justifiy the > merits of the use of __read_mostly on it. > That would be my fault! (sorry) given the rationale below, the patch I sent really doesn't need the hint. Thanks for the extra bit of education here. (not an excuse) In a glance over the source tree, though, it seems most of the hinting cases are doing it in the misguided way. > include/linux/cache.h | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/include/linux/cache.h b/include/linux/cache.h > index 750621e41d1c..8106fb304fa7 100644 > --- a/include/linux/cache.h > +++ b/include/linux/cache.h > @@ -15,8 +15,14 @@ > > /* > * __read_mostly is used to keep rarely changing variables out of frequently > - * updated cachelines. If an architecture doesn't support it, ignore the > - * hint. > + * updated cachelines. Its use should be reserved for data that is used > + * frequently in hot paths. Performance traces can help decide when to use > + * this. You want __read_mostly data to be tightly packed, so that in the > + * best case multiple frequently read variables for a hot path will be next > + * to each other in order to reduce the number of cachelines needed to > + * execute a critial path. We should be mindful and selective of its use. > + * ie: if you're going to use it please supply a *good* justification in your > + * commit log > */ > #ifndef __read_mostly > #define __read_mostly > -- > 2.25.1 > Acked-by: Rafael Aquini