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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95B78C61DA4 for ; Thu, 9 Mar 2023 07:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230157AbjCIH2C (ORCPT ); Thu, 9 Mar 2023 02:28:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbjCIH1g (ORCPT ); Thu, 9 Mar 2023 02:27:36 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02807DC3BA for ; Wed, 8 Mar 2023 23:27:28 -0800 (PST) Date: Thu, 9 Mar 2023 08:27:24 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1678346846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=xrMc8nS/afdgh6gNuFLpCc38mamPBkofjth4qTI6hP0=; b=bD3wC6HPU2sqGOyKRj3T8xblfHthFIn2+R9QIQOi6rVOP9E1eDxZTAZe3aGwZdVA3esrws dvchu+Fc5FvDIgcShDmdi1LwoBqrsxONJY+WKolOksJ8yyhODE/3+SGoZo3n0DllvCCvIx K91+YISck+4LFrWIxXzJy1oJAMn29p5dUH0MqGzAhaTDCl2gIrmQLnpJPZBGxHRHuqc4MB OsRHDbIcmLpKt7t2jLma1iE+nxzjPJRIJvb4KCoP9GfbsOadQl7aiT0M8qWaAArM4W6+7r rOQKjeATeCZoBQk5Xn1Uo7ugXEVPDkodJsB8TY77g184FxHxx5ZGbXURYtkoaQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1678346846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=xrMc8nS/afdgh6gNuFLpCc38mamPBkofjth4qTI6hP0=; b=UwAVc7SBBnKFf8HGDVMxL4vLOjoj8WXKNjOEqjkXVgROsIH/BqcyWEe284mvM6s7/IZ08K JMbVPOodaYCmb6Ag== From: Sebastian Andrzej Siewior To: linux-kernel@vger.kernel.org Cc: Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Ingo Molnar , Juri Lelli , Mel Gorman , Peter Zijlstra , Steven Rostedt , Thomas Gleixner , Valentin Schneider , Vincent Guittot Subject: [PATCH RFC] preempt: Put preempt_enable() within an instrumentation*() section. Message-ID: <20230309072724.3F6zRkvw@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Callers of preempt_enable() can be within an noinstr section leading to: | vmlinux.o: warning: objtool: native_sched_clock+0x97: call to preempt_schedule_notrace_thunk() leaves .noinstr.text section | vmlinux.o: warning: objtool: kvm_clock_read+0x22: call to preempt_schedule_notrace_thunk() leaves .noinstr.text section | vmlinux.o: warning: objtool: local_clock+0xb4: call to preempt_schedule_notrace_thunk() leaves .noinstr.text section | vmlinux.o: warning: objtool: enter_from_user_mode+0xea: call to preempt_schedule_thunk() leaves .noinstr.text section | vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x140: call to preempt_schedule_thunk() leaves .noinstr.text section | vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0xf2: call to preempt_schedule_thunk() leaves .noinstr.text section | vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0xea: call to preempt_schedule_thunk() leaves .noinstr.text section This only happens on CONFIG_PREEMPT+ due to the conditional call into the scheduler. Signed-off-by: Sebastian Andrzej Siewior --- include/linux/preempt.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/preempt.h b/include/linux/preempt.h index 12f59cdaaedda..05338f00a5907 100644 --- a/include/linux/preempt.h +++ b/include/linux/preempt.h @@ -238,15 +238,21 @@ do { \ #define preempt_enable() \ do { \ barrier(); \ - if (unlikely(preempt_count_dec_and_test())) \ + if (unlikely(preempt_count_dec_and_test())) { \ + instrumentation_begin(); \ __preempt_schedule(); \ + instrumentation_end(); \ + } \ } while (0) #define preempt_enable_notrace() \ do { \ barrier(); \ - if (unlikely(__preempt_count_dec_and_test())) \ + if (unlikely(__preempt_count_dec_and_test())) { \ + instrumentation_begin(); \ __preempt_schedule_notrace(); \ + instrumentation_end(); \ + } \ } while (0) #define preempt_check_resched() \ -- 2.39.2