From patchwork Tue Jul 7 17:36:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 11649447 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 7AB8D92A for ; Tue, 7 Jul 2020 17:36:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 471CC20708 for ; Tue, 7 Jul 2020 17:36:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="fcgFYG96" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 471CC20708 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=fb.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3FAC96B0055; Tue, 7 Jul 2020 13:36:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3AE586B0071; Tue, 7 Jul 2020 13:36:25 -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 2752E6B0085; Tue, 7 Jul 2020 13:36:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0097.hostedemail.com [216.40.44.97]) by kanga.kvack.org (Postfix) with ESMTP id 10FF26B0055 for ; Tue, 7 Jul 2020 13:36:25 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C1A5F1EE6 for ; Tue, 7 Jul 2020 17:36:24 +0000 (UTC) X-FDA: 77011983888.22.sack20_210e36426eb6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 5284918038E6B for ; Tue, 7 Jul 2020 17:36:24 +0000 (UTC) X-Spam-Summary: 1,0,0,b669c1dfe982e9ff,d41d8cd98f00b204,prvs=4457d3df13=guro@fb.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1437:1513:1515:1516:1518:1521:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2740:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:3872:3874:4321:5007:6261:6653:7903:10004:10400:11026:11658:11914:12043:12114:12297:12438:12555:12895:13069:13227:13229:13311:13357:14096:14097:14181:14394:14721:21080:21433:21450:21627:21939:21990:30012:30054:30064,0,RBL:67.231.153.30:@fb.com:.lbl8.mailshell.net-64.201.201.201 62.12.0.100;04yfkungn7upbgye7sao3k3pbmmopophw73at4ojetdan9h9zqtbcgrw8d5yj4n.wf9zuawewxjgk44hxzbia134g8s13mns4nz9argoqhb8xkxhk343zfjs6tgjohn.c-lbl8.mailshell.net-223.238.255.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:24,LUA_SUMMARY:none X-HE-Tag: sack20_210e36426eb6 X-Filterd-Recvd-Size: 4152 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 17:36:23 +0000 (UTC) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.42/8.16.0.42) with SMTP id 067HKvFa019860 for ; Tue, 7 Jul 2020 10:36:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=+V0/S8aoxdD+9WfM0wVUP71CBpAoqsAxGFDi+cevcRk=; b=fcgFYG96jeH2YCnHiID+EUvIkw/NZJEDAhzQOVpqIoO8a0ntN6UshhX6QuYes7S1G8Lk tsDjBIYZXxewrnEK2xYT6R1I9lKD2Edd/1uU75lP4xp/bWM3E23XNlU8AMQzNSPqpL7v /S/hJSbpRjvkL0qktD60PlMKdqhF+ixAbnc= Received: from mail.thefacebook.com ([163.114.132.120]) by m0089730.ppops.net with ESMTP id 322n90nst4-12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 07 Jul 2020 10:36:23 -0700 Received: from intmgw002.06.prn3.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:21d::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 7 Jul 2020 10:36:19 -0700 Received: by devvm1096.prn0.facebook.com (Postfix, from userid 111017) id 57716CDE8D7; Tue, 7 Jul 2020 10:36:17 -0700 (PDT) Smtp-Origin-Hostprefix: devvm From: Roman Gushchin Smtp-Origin-Hostname: devvm1096.prn0.facebook.com To: Andrew Morton CC: Johannes Weiner , Michal Hocko , Shakeel Butt , , Vlastimil Babka , , , Roman Gushchin Smtp-Origin-Cluster: prn0c01 Subject: [PATCH 3/3] mm: kmem: switch to static_branch_likely() in memcg_kmem_enabled() Date: Tue, 7 Jul 2020 10:36:12 -0700 Message-ID: <20200707173612.124425-3-guro@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200707173612.124425-1-guro@fb.com> References: <20200707173612.124425-1-guro@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-07_09:2020-07-07,2020-07-07 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 lowpriorityscore=0 adultscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 cotscore=-2147483648 phishscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007070120 X-FB-Internal: deliver X-Rspamd-Queue-Id: 5284918038E6B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: Currently memcg_kmem_enabled() is optimized for the kernel memory accounting being off. It was so for a long time, and arguably the reason behind was that the kernel memory accounting was initially an opt-in feature. However, now it's on by default on both cgroup v1 and cgroup v2, and it's on for all cgroups. So let's switch over to static_branch_likely() to reflect this fact. Unlikely there is a significant performance difference, as the cost of a memory allocation and its accounting significantly exceeds the cost of a jump. However, the conversion makes the code look more logically. Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt Acked-by: Vlastimil Babka --- include/linux/memcontrol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index b8f52a3fed90..ab9322215b2e 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1456,7 +1456,7 @@ void memcg_put_cache_ids(void); static inline bool memcg_kmem_enabled(void) { - return static_branch_unlikely(&memcg_kmem_enabled_key); + return static_branch_likely(&memcg_kmem_enabled_key); } static inline bool memcg_kmem_bypass(void)