From patchwork Thu May 7 16:14:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11534393 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AED4514C0 for ; Thu, 7 May 2020 16:14:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8574A2083B for ; Thu, 7 May 2020 16:14:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8574A2083B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BEDAA900005; Thu, 7 May 2020 12:14:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BC554900002; Thu, 7 May 2020 12:14:29 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADA62900005; Thu, 7 May 2020 12:14:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0008.hostedemail.com [216.40.44.8]) by kanga.kvack.org (Postfix) with ESMTP id 975CE900002 for ; Thu, 7 May 2020 12:14:29 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2C7E814534 for ; Thu, 7 May 2020 16:14:29 +0000 (UTC) X-FDA: 76790420658.04.week46_9ffbfd237a20 X-Spam-Summary: 2,0,0,537ba867a74a372d,d41d8cd98f00b204,mcgrof@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1437:1515:1534:1541:1711:1730:1747:1777:1792:2194:2198:2199:2200:2393:2559:2562:2693:2731:2895:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:5007:6261:7903:9108:10004:11232:11658:11914:12297:12517:12519:12555:12895:13069:13311:13357:13894:14096:14181:14384:14394:14721:21080:21444:21451:21627:30034:30054,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: week46_9ffbfd237a20 X-Filterd-Recvd-Size: 3780 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 May 2020 16:14:28 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id l25so3017521pgc.5 for ; Thu, 07 May 2020 09:14:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K01c3myVTwjqfRxKpVK6bNm+Qr9pA/B7t1+trJLymis=; b=rKm4BX6qWV867k3s4z+LETQHuS5+6L17SMbd5DJkOpOfj1+VHXvJikiylvl3icLh3P bCQ2y19VtLOk7OjqDKg3fRzdHVMSKYlp7AgKXPBIJ+a0mPJ+msbbyvIueIR5N0jagy/+ 75YFByRRjd8gAuL7ypHgbSkbia1XNVrcB57+wx9MlIB1c+nRjdQNGOpnzSxBe5V/qmY1 NrXZ1Kx1D8L8h6xUVxN7DiQHUqhusV0ZKaNE3M8vAP/yZTdsCUIXov0yOio+FMLA7ClQ Wkj318jODuNTKnpei0CMDKXfYnXSg3VPYvBK19SZJCCqeqL7jP/s14bLV5kpGRpnLbiH 5WNw== X-Gm-Message-State: AGi0PuYXILcUt2uxfWvGGeoKLMo7ZGdAYj3Al4eyNV31+qSD2hJBibLE fL4mt1HWzjq02t7r0bweJ8Y= X-Google-Smtp-Source: APiQypJlK3bEqBCOWQ9A1P7qBNuXOr+1NhJTCNPPunzRaibPtjOJ3Mug/c0efwn5onWc1A+geXg7uQ== X-Received: by 2002:a62:343:: with SMTP id 64mr14719426pfd.47.1588868067667; Thu, 07 May 2020 09:14:27 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id x193sm5626460pfd.54.2020.05.07.09.14.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 09:14:26 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id D578A403EA; Thu, 7 May 2020 16:14:25 +0000 (UTC) From: Luis Chamberlain To: cl@linux.com, akpm@linux-foundation.org Cc: arnd@arndb.de, willy@infradead.org, aquini@redhat.com, keescook@chromium.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH v2] mm: expand documentation over __read_mostly Date: Thu, 7 May 2020 16:14:24 +0000 Message-Id: <20200507161424.2584-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000023, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: __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 its use. Acked-by: Christoph Lameter Signed-off-by: Luis Chamberlain Reviewed-by: Kees Cook Acked-by: Rafael Aquini --- This v2 just has a few spelling fixes. 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 critical 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