Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp602632pxx; Thu, 29 Oct 2020 09:54:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLVfdWVPELq+ghPmXsnIHF2KxZ9bkvoGWMPxuS0xenBfR+9/BmoNv25IMEpRO7IBICX/Kh X-Received: by 2002:a17:906:d7ad:: with SMTP id pk13mr2613638ejb.196.1603990473807; Thu, 29 Oct 2020 09:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603990473; cv=none; d=google.com; s=arc-20160816; b=ibJsNk29G2UuwmIG2vLa0j0PiOUTswdxNLOHd1QyQ1EleKkdFbfoCgHW0fboT4BJ/l D7tkZ1mbf2C2LGT9vjixxkA1KjXR6JZE6Fsb6cZGax7AxxQ0QnxzTxfgAZgPhuRF8gEH 9Oolng9zJyAbr9iRKDGpgwER4BzkIk+ZmzqgkDXyeRdFjqjeEXpH5IqNmjecZfZLbCjh SPU/Bwi59iM1HQyIgEpi0foeyiKIW+I0ANH7kGqkMJQ22oOmxY2oWHu2jgMdFwhKOW/+ KNh/BwLhC9EU0Gu1z377H7xyD+Hizq8gOqEv9HMvWIuE6wvMHpK62dcQfMQqwDjAJz4q 3bPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/Wc02XaEw+MkdyCkLxl/H0wu90RBnxL4HVWq12itskk=; b=nSwr4S2IDf25ne42GuWYZ+eb+RtG9m0usPDhNFZZs9qesici8PIJqm1YI0hdI8Polh o7vZc7yn6OSm1r34+Ck0gFhyj19xMT7rkU98i7glVxx3exCIwZ7rWb+y0O8j67EFv83o lPEoWxV9xKA3Zmjp77rBt5C1XE8+n7FggHlzrzZWB2sli3Ziv5m79fTT8rhoCYV2zQAu r3f/ZjkF40fg9dlhU9zK5f863BSYdFjHElljh1jDdxP8gjmw+Tr67/AHvrMFXX+3XapU CnbmRnkMT5NDuv6loZeMnD7vWT/HbIL/25hVsHuXTx2F5jJaVWxlQlBcPjkP3XeCESSr SXUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FDcGD5Fk; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si2220154ejk.344.2020.10.29.09.54.11; Thu, 29 Oct 2020 09:54:33 -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=@gmail.com header.s=20161025 header.b=FDcGD5Fk; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728337AbgJ2Qvr (ORCPT + 99 others); Thu, 29 Oct 2020 12:51:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727143AbgJ2Quh (ORCPT ); Thu, 29 Oct 2020 12:50:37 -0400 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32A5EC0613D6; Thu, 29 Oct 2020 09:50:37 -0700 (PDT) Received: by mail-lf1-x141.google.com with SMTP id y184so2225521lfa.12; Thu, 29 Oct 2020 09:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/Wc02XaEw+MkdyCkLxl/H0wu90RBnxL4HVWq12itskk=; b=FDcGD5FkdTzZb1Ffd7DdaIXkH4AYeDKFsHRhdg9FGozcGwv+vG2fKsv/h6hjx0z0SX O2XqOcoc5ES0KmXI1Q+TtkdiKLgqqVDHmbLgxxJp88A2pB30GT9QQUsG4mc7QJCbFlmo otm7VztlG5QJESsvV+xuICpihxMkYGasDQuqFKgiimsrtfVr94K1oZwo1v5qxEkwR471 xwtVWhPbTclzuw8SZzAl2UKem8Y0V5YpCcdFY6Lr4aKt4YQbkWn7u6UUrd0VpxD+Lls3 8Eh7gRIfvR2KWraCbjBwLrFDxLQCHMLlb5IpT4XfSHwK+HevUh96sg96D/Af3Zk/ZNX7 eO4A== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=/Wc02XaEw+MkdyCkLxl/H0wu90RBnxL4HVWq12itskk=; b=AXaI7Ms6I6F9unvZyNzxXJAn//Mh6FYTsArAFH4FBdlYSuo8GogYkZzCt2rdT7L8T6 KTj98FgzKrg55C7dGaEJy+KAsZcfl/KlG+iShLZ8TmfYlmQ0h0txacBkIWxyP0gfeyaU Vcqnqa0eZGCG3qF6ucf7kUKuPa+ywGGf4NAFBViDuzSTX28BziVQnkZ2QAAH6Ac0DajP fjv13I/wAZIBNz9Gy6wjKFuH+BDub6V3SIC2h2uMPQx+z3RZ82tltXZNTRx3wLqhTJUk 0A+3av1YNtMf8LZCkctPsvAYFAcUEqj2yXa4QneLHIf0tAkaZTCO7wdW65yhb/3CFINz DnMQ== X-Gm-Message-State: AOAM531Upitj4/rdZ0K9hGH9mGmvFabLYsiTXejQe8cUFzgFSWTm6lXA 4P+OcUniE2O4BtAvp2dq+nSApUtvag3wLw== X-Received: by 2002:a05:6512:36c7:: with SMTP id e7mr1898529lfs.206.1603990235320; Thu, 29 Oct 2020 09:50:35 -0700 (PDT) Received: from pc638.lan (h5ef52e31.seluork.dyn.perspektivbredband.net. [94.245.46.49]) by smtp.gmail.com with ESMTPSA id s1sm331832lfd.236.2020.10.29.09.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 09:50:34 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: LKML , RCU , "Paul E . McKenney" Cc: Andrew Morton , Peter Zijlstra , Michal Hocko , Thomas Gleixner , "Theodore Y . Ts'o" , Joel Fernandes , Sebastian Andrzej Siewior , Uladzislau Rezki , Oleksiy Avramchenko Subject: [PATCH 03/16] preempt: Make preempt count unconditional Date: Thu, 29 Oct 2020 17:50:06 +0100 Message-Id: <20201029165019.14218-3-urezki@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201029165019.14218-1-urezki@gmail.com> References: <20201029165019.14218-1-urezki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner The handling of preempt_count() is inconsistent accross 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 seperate functions for seperate 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 accross 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: Uladzislau Rezki (Sony) --- kernel/Kconfig.preempt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt index bf82259cff96..3f4712ff073b 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.20.1