Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp338999ybj; Wed, 6 May 2020 19:20:13 -0700 (PDT) X-Google-Smtp-Source: APiQypIh/Jl5hCtCh0lH9zf9BvTNGTYOdmTCu0wgxwRJ8kpE0/N/PHNwJv1cuUysAYxlBLt0nTDv X-Received: by 2002:a17:906:809:: with SMTP id e9mr9702588ejd.81.1588818013198; Wed, 06 May 2020 19:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588818013; cv=none; d=google.com; s=arc-20160816; b=yIFnjv3RImbnoOVXjfjJOVAmmkg1T3xMjZLFvEUUQmPyKspnGQa6R+8ZvT+9h56KIb az6RTqnLTiQFhTf1aTyZSa+X/ptJa+fl9qCfxUo7dOBGjUZNCqqEEzjxkWp2Br5SauVL ZB3PJAgZyOCXPt/TU0vU9N8MwMhU7Hy+yCzYrAzcG/C/NIOfbNKXKsaLdm78ZrnP4ECK R8I6ubPSrkifVNImJcdSrhQDnSOog7ViKCYpbqqsEvt49WINQkTF+lE+dfmQis4xlvIv Z+iqyzu3fEqk36HqEL+3tx3MK8zzQLZHSElb1tfxqy8ZYYWiGHuuNWiYb+l+ylieY1pL UMDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=4GE42jOdua+ii9NEsVA32zpvW4/j25e1V7wWknNFBjw=; b=lEXxKIE5z8VK6sEs2nQoGarCIoSieFyU+3LN/dzGnZmPqSLFUMvu60NHC6Hdr/qri0 CjrKrghpuxgHYnU0SqCVqaUvPTYAlJ5E9YD3IkFp1NCZWBfKUTe4jIPLztL0fvsB75s4 DXM757dJh07IilHoyZllsOFllU+fiVSsar9AnKyCxjyW5vLNlHrX0pVla/sOD9sAjjst 85bWQ5OVCN6q0Gsm8y1xbFRzt3CrUXqO7VdA1qQr7rWGmKJARTKBSQIA6wyYATeoMPvE eXr7AlSO/JMb6CY2I0bDv5CvHQU/2Dsjh9+/g/QBdnLHhA6Gd7WuF1jUx+2GEwWTSU6F WYWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XvRe62MB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gq16si2077592ejb.111.2020.05.06.19.19.48; Wed, 06 May 2020 19:20:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XvRe62MB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728066AbgEFXgX (ORCPT + 99 others); Wed, 6 May 2020 19:36:23 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:29251 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727917AbgEFXgX (ORCPT ); Wed, 6 May 2020 19:36:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588808182; 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=XvRe62MB2z3+m4qWnwWPaGIYbX88TDhS8gUDxNb3Heny40hRRt+msMO70J0Z/ixEUqiX9k E2TieRnAqzUXeg6EsUBh5ftmJfXoSUi+FuyFsevr80tMc3k4ofSfDTkzUOTQSYD0UDrHhi q++Iimf+p4U3Kmx0OAk5cOK8eFI1Z98= 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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