From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89062C433EF for ; Thu, 11 Nov 2021 10:56:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EAEF61268 for ; Thu, 11 Nov 2021 10:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232778AbhKKK7F (ORCPT ); Thu, 11 Nov 2021 05:59:05 -0500 Received: from foss.arm.com ([217.140.110.172]:36974 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbhKKK7D (ORCPT ); Thu, 11 Nov 2021 05:59:03 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 54C17D6E; Thu, 11 Nov 2021 02:56:14 -0800 (PST) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.196.57]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3BE0E3F70D; Thu, 11 Nov 2021 02:56:12 -0800 (PST) From: Valentin Schneider To: Marco Elver Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linuxppc-dev@lists.ozlabs.org, linux-kbuild@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Frederic Weisbecker , Mike Galbraith , Dmitry Vyukov , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Steven Rostedt , Masahiro Yamada , Michal Marek , Nick Desaulniers Subject: Re: [PATCH v2 2/5] preempt/dynamic: Introduce preempt mode accessors In-Reply-To: References: <20211110202448.4054153-1-valentin.schneider@arm.com> <20211110202448.4054153-3-valentin.schneider@arm.com> Date: Thu, 11 Nov 2021 10:56:06 +0000 Message-ID: <874k8jrmex.mognet@arm.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/11/21 09:54, Marco Elver wrote: > On Wed, Nov 10, 2021 at 08:24PM +0000, Valentin Schneider wrote: > [...] >> +#ifdef CONFIG_PREEMPT_DYNAMIC >> + >> +extern bool is_preempt_none(void); >> +extern bool is_preempt_voluntary(void); >> +extern bool is_preempt_full(void); >> + >> +#else >> + >> +#define is_preempt_none() IS_ENABLED(CONFIG_PREEMPT_NONE) >> +#define is_preempt_voluntary() IS_ENABLED(CONFIG_PREEMPT_VOLUNTARY) >> +#define is_preempt_full() IS_ENABLED(CONFIG_PREEMPT) >> + >> +#endif >> + >> +#define is_preempt_rt() IS_ENABLED(CONFIG_PREEMPT_RT) >> + > > Can these callables be real functions in all configs, making the > !DYNAMIC ones just static inline bool ones? That'd catch invalid use in > #if etc. in all configs. > Ack >> /* >> * Does a critical section need to be broken due to another >> * task waiting?: (technically does not depend on CONFIG_PREEMPTION, >> diff --git a/kernel/sched/core.c b/kernel/sched/core.c >> index 97047aa7b6c2..9db7f77e53c3 100644 >> --- a/kernel/sched/core.c >> +++ b/kernel/sched/core.c >> @@ -6638,6 +6638,17 @@ static void __init preempt_dynamic_init(void) >> } >> } >> >> +#define PREEMPT_MODE_ACCESSOR(mode) \ >> + bool is_preempt_##mode(void) \ >> + { \ >> + WARN_ON_ONCE(preempt_dynamic_mode == preempt_dynamic_undefined); \ >> + return preempt_dynamic_mode == preempt_dynamic_##mode; \ >> + } > > This needs an EXPORT_SYMBOL, so it's usable from modules like the > kcsan_test module. Ah, wasn't sure about that one, thanks! From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C0B3C433F5 for ; Thu, 11 Nov 2021 10:56:46 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96A3E60F5B for ; Thu, 11 Nov 2021 10:56:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 96A3E60F5B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4HqdvJ0PMLz3cCK for ; Thu, 11 Nov 2021 21:56:44 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=arm.com (client-ip=217.140.110.172; helo=foss.arm.com; envelope-from=valentin.schneider@arm.com; receiver=) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lists.ozlabs.org (Postfix) with ESMTP id 4Hqdtr07lpz2yMq for ; Thu, 11 Nov 2021 21:56:17 +1100 (AEDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 54C17D6E; Thu, 11 Nov 2021 02:56:14 -0800 (PST) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.196.57]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3BE0E3F70D; Thu, 11 Nov 2021 02:56:12 -0800 (PST) From: Valentin Schneider To: Marco Elver Subject: Re: [PATCH v2 2/5] preempt/dynamic: Introduce preempt mode accessors In-Reply-To: References: <20211110202448.4054153-1-valentin.schneider@arm.com> <20211110202448.4054153-3-valentin.schneider@arm.com> Date: Thu, 11 Nov 2021 10:56:06 +0000 Message-ID: <874k8jrmex.mognet@arm.com> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Marek , linux-kbuild@vger.kernel.org, Peter Zijlstra , Frederic Weisbecker , Mike Galbraith , Nick Desaulniers , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Paul Mackerras , Steven Rostedt , Masahiro Yamada , linuxppc-dev@lists.ozlabs.org, Ingo Molnar , Dmitry Vyukov Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 11/11/21 09:54, Marco Elver wrote: > On Wed, Nov 10, 2021 at 08:24PM +0000, Valentin Schneider wrote: > [...] >> +#ifdef CONFIG_PREEMPT_DYNAMIC >> + >> +extern bool is_preempt_none(void); >> +extern bool is_preempt_voluntary(void); >> +extern bool is_preempt_full(void); >> + >> +#else >> + >> +#define is_preempt_none() IS_ENABLED(CONFIG_PREEMPT_NONE) >> +#define is_preempt_voluntary() IS_ENABLED(CONFIG_PREEMPT_VOLUNTARY) >> +#define is_preempt_full() IS_ENABLED(CONFIG_PREEMPT) >> + >> +#endif >> + >> +#define is_preempt_rt() IS_ENABLED(CONFIG_PREEMPT_RT) >> + > > Can these callables be real functions in all configs, making the > !DYNAMIC ones just static inline bool ones? That'd catch invalid use in > #if etc. in all configs. > Ack >> /* >> * Does a critical section need to be broken due to another >> * task waiting?: (technically does not depend on CONFIG_PREEMPTION, >> diff --git a/kernel/sched/core.c b/kernel/sched/core.c >> index 97047aa7b6c2..9db7f77e53c3 100644 >> --- a/kernel/sched/core.c >> +++ b/kernel/sched/core.c >> @@ -6638,6 +6638,17 @@ static void __init preempt_dynamic_init(void) >> } >> } >> >> +#define PREEMPT_MODE_ACCESSOR(mode) \ >> + bool is_preempt_##mode(void) \ >> + { \ >> + WARN_ON_ONCE(preempt_dynamic_mode == preempt_dynamic_undefined); \ >> + return preempt_dynamic_mode == preempt_dynamic_##mode; \ >> + } > > This needs an EXPORT_SYMBOL, so it's usable from modules like the > kcsan_test module. Ah, wasn't sure about that one, thanks!