Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3383821pxk; Mon, 28 Sep 2020 16:33:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnRqyzyJFvPOaGi73GlruzWoinbHTz22gWKEYhpaRkg8LStEnGOTvf48i5P3gkJ8RnQ8tT X-Received: by 2002:a17:906:5008:: with SMTP id s8mr1194632ejj.408.1601335987995; Mon, 28 Sep 2020 16:33:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601335987; cv=none; d=google.com; s=arc-20160816; b=zkrTMns2GC9xILBFtaS0bsEcoR/UPr2+6hzq7UGlh1QtJAEP5pRe1/jsxhdxU5ItAu NgC3DP+9sxnomhtbkQU7pqmfix5KA1H74BLh/s1oNcAChBCt0+3LUL/Bu9E9OllTeJKP 8L85Ld1mzncYlpN2TeC82xNLNNq7uUtzCjBS9WFSKkblpCZoUitVir2H+FACqBMwHix8 XWrNxJW6FK7dULTbVkg1Fv1rZFY96fO9mxZIa6TkwqgDi+PPIps9t3rIoQ1EoGFGETTT cDnpUf/y5dy6COf9jFETNgjDLBqGK6KLPFtAqfksW8sZlDQGy+HTgk5jKwpFACzjLdfg gjzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=ps4TEZoEvRKLd0hz3upnOM+mkfYbZgIp2Lo8N9VbE8E=; b=T0xc7RY5nVF38yQSKUvYgHY6DDGGkXw/hN1yvb6q0ac/HWeWWAGnKqh/1wCHu09JzR TsvGWTegjDYJMF5xTY73uovBgPHIoz3AXZg/KZLZnKdastlIj28Fkl3fQH2H2QfVUJIi 6u6Pok67unACph56nuC4IfzfbT2kT+LN4c0+VJ+FkdmhgkRwc+ICVs6wlZhNUYAqI6oq 7QqXmWHbx+iEGPjuBVWpa2Sobz/xqNF+6PbyzUzqkfeCCt1T7777wWlSaz3ioAhPYlQM /HxpgqhCla43ldzfIV+1XjkAj+eCfm05Zp8CvJS5Nojf7ldiCtjd2bfK2OuO3VHEtHmG 273Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GWHC7E+u; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si1459516ejc.723.2020.09.28.16.32.38; Mon, 28 Sep 2020 16:33:07 -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=@kernel.org header.s=default header.b=GWHC7E+u; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727227AbgI1XbG (ORCPT + 99 others); Mon, 28 Sep 2020 19:31:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:54254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727000AbgI1XbF (ORCPT ); Mon, 28 Sep 2020 19:31:05 -0400 Received: from paulmck-ThinkPad-P72.home (unknown [50.45.173.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 84651216C4; Mon, 28 Sep 2020 23:31:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601335864; bh=1uk2ydITKCZXPh14bJoTz3qsavwW7DyPhAI3heHlzN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GWHC7E+us4aSzvA+LnNsw6pnIOCtCdZ351J38ylg7PONZ7bbtknnV7nEk97sTIo9Z wmPN9PL7V3neyYB+gyBlK7XoMvZL/oaTrDan6P3Y9J3vPYM4yE9Wlg43NinpWUJt8i ql8U1eIaF4E0CTzpb65MQ9xuprYVBNfMq9MUqjdw= From: paulmck@kernel.org To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel@joelfernandes.org, mhocko@kernel.org, mgorman@techsingularity.net, torvalds@linux-foundation.org, "Paul E . McKenney" Subject: [PATCH tip/core/rcu 02/15] preempt: Make preempt count unconditional Date: Mon, 28 Sep 2020 16:30:49 -0700 Message-Id: <20200928233102.24265-2-paulmck@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20200928233041.GA23230@paulmck-ThinkPad-P72> References: <20200928233041.GA23230@paulmck-ThinkPad-P72> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner The handling of preempt_count() is inconsistent across kernel configurations. On kernels which have PREEMPT_COUNT=n preempt_disable/enable() and the lock/unlock functions are not affecting the preempt count, only local_bh_disable/enable() and _bh variants of locking, soft interrupt delivery, hard interrupt and NMI context affect it. It's therefore impossible to have a consistent set of checks which provide information about the context in which a function is called. In many cases it makes sense to have separate functions for separate contexts, but there are valid reasons to avoid that and handle different calling contexts conditionally. The lack of such indicators which work on all kernel configuratios is a constant source of trouble because developers either do not understand the implications or try to work around this inconsistency in weird ways. Neither seem these issues be catched by reviewers and testing. Recently merged code does: gfp = preemptible() ? GFP_KERNEL : GFP_ATOMIC; Looks obviously correct, except for the fact that preemptible() is unconditionally false for CONFIF_PREEMPT_COUNT=n, i.e. all allocations in that code use GFP_ATOMIC on such kernels. Attempts to make preempt count unconditional and consistent have been rejected in the past with handwaving performance arguments. Freshly conducted benchmarks did not reveal any measurable impact from enabling preempt count unconditionally. On kernels with CONFIG_PREEMPT_NONE or CONFIG_PREEMPT_VOLUNTARY the preempt count is only incremented and decremented but the result of the decrement is not tested. Contrary to that enabling CONFIG_PREEMPT which tests the result has a small but measurable impact due to the conditional branch/call. It's about time to make essential functionality of the kernel consistent across the various preemption models. Enable CONFIG_PREEMPT_COUNT unconditionally. Follow up changes will remove the #ifdeffery and remove the config option at the end. Signed-off-by: Thomas Gleixner Signed-off-by: Paul E. McKenney --- kernel/Kconfig.preempt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt index bf82259..3f4712f 100644 --- a/kernel/Kconfig.preempt +++ b/kernel/Kconfig.preempt @@ -75,8 +75,7 @@ config PREEMPT_RT endchoice config PREEMPT_COUNT - bool + def_bool y config PREEMPTION bool - select PREEMPT_COUNT -- 2.9.5