From patchwork Thu Mar 9 07:27:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 66622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp154035wrd; Wed, 8 Mar 2023 23:47:36 -0800 (PST) X-Google-Smtp-Source: AK7set991HnPcOhv+rCZ8Hi5a96ADzeUPcsk+vTWEdDwjHOIVl3J6VSBfzgjObGOuJDc0GnQcNfM X-Received: by 2002:a05:6a20:8e28:b0:cc:b3da:822a with SMTP id y40-20020a056a208e2800b000ccb3da822amr21920562pzj.29.1678348056231; Wed, 08 Mar 2023 23:47:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678348056; cv=none; d=google.com; s=arc-20160816; b=BlA09ae4zvxkAKnBmdG8dOWQLDvlTgI5tsfRFsC58uWKkGtNpNag9Uin10i6c6FIbl 4KHJBXnRFUU8rOAKqd6eURzBTRWkrZKjX6w7aotUR0wdyqv9lSw/pJqPOtB/lCw8w32J tiVgktxoDmi05/J2p38rCU5sN8rrHpVxa+YB07+uo1tqNNTx1XiwnDbBZYtvba/rXCX2 sHC8i2ALqi8tfSe3OKm9ZVfVnJ1sGIfTZq4eRJhHEvhoFBUh/xUPabIZKYRs+XMBrh55 FFdxTtaUvPaUMpkygNjINTTaH9Bp2d1kCsxW8s/fgj+txtZcX8LC6ECJK7jh5ZY6h6Kr qvtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:dkim-signature:dkim-signature:date; bh=xrMc8nS/afdgh6gNuFLpCc38mamPBkofjth4qTI6hP0=; b=nYGZVVyMH+wZeB+FZyplE13wmCjmH7mylfqOSVyDtpJFiiLm72Gu8rNKAikVQbpUsm etfK3TTCjMtS/KM/jcVQiVgEIGYsuMnqc/PAICB4nDTLK1eTOCpFaFJARHYQFGRv29xn v1M9XGq6h7snIioPCodreEdb9fo3hF/2lhiBk6er9v2PZ0VobGn1tWlWsSF97NIBxd4v nuUhdNV2PUjCaPB/owrUUPqYViPJEipoOEWPqkGs7b25BYlWLEHQeYG+0cyj+oGb1bGd j6ti8xnuCYMNYpk60wYMDj29tBVfCk2a8jTp5RNumEeuR+3tKQ5qdHI2bj+rdQkgkk2o TMLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bD3wC6HP; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h19-20020a63df53000000b004fb647a765esi16202284pgj.329.2023.03.08.23.47.23; Wed, 08 Mar 2023 23:47:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bD3wC6HP; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230170AbjCIH2B (ORCPT + 99 others); Thu, 9 Mar 2023 02:28:01 -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-Disposition: inline X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759875491406784024?= X-GMAIL-MSGID: =?utf-8?q?1759875491406784024?= 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() \