From nobody Thu Apr 2 21:36:43 2026 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 A07EBC6FA82 for ; Wed, 21 Sep 2022 01:27:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230345AbiIUB1Y (ORCPT ); Tue, 20 Sep 2022 21:27:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231574AbiIUB1A (ORCPT ); Tue, 20 Sep 2022 21:27:00 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F2D45756C for ; Tue, 20 Sep 2022 18:26:12 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id h11-20020a170902f54b00b001780f0f7ea7so2788572plf.9 for ; Tue, 20 Sep 2022 18:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=Zc82LmVew5/T1CkEfW5rs6gkMi/t3IMOs+9o8CakWjo=; b=Fg1NZ+GWt94sDG8qDDqXcoZpGfdn5EwhJKMaEkIvUBW+dfLv4ocTBHL/P2LHHuDHVf +YYIXUTg3zmTr0pzM5fVxhctKGC9WYxIaY/0zXV2wqIVU3wE2vLSLHvFfdTJU+2gfq0L voLAPO6S+ieDU8UHyW94wVMreNyGBaq/k3bkQM0qGa/I83t1jC7cd4PvfPpYCIyMbQbM J1faxAgvLya80zAXG8IitYwy+rlkNXA9wIh7F0b0Q3FWarAz6K3tolu8CIqvXHmDRAHI cEFHuUIkYjKgH2XIPoGgrLcouzQuWvfLyEyYUvVmNJOSTdu8TB9CmkwRkMndLAO0Pk3w s/2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=Zc82LmVew5/T1CkEfW5rs6gkMi/t3IMOs+9o8CakWjo=; b=ZEFaYwG/BpJZC+/gefyitmzJPz8WRy0l/qrKaedBd+/nOkgtUtkDlLzy4lw1vF3lin NWLR/IOK86pQYkqB0M6OnlaTkIMYWi9ORbyDHITGS3a/utIOhtQZ7mwj5LPQH2UPefQm Nqrna7JF+Ol0ToVsHgEqwQlzJLulLg1xApDccTfUfok6ACakd88D9Kb89A27HrlHwbfX O8XQYGciGNtQGOU9Xf5MsYUHruvFaYRuagf1uaZpEPpy21Ya6oc4WVHA/FWl5l+rAmLp VNzJHCe/l6p+GqG0gHZf1aO1unx0fGTPRp3Tobg6OdbxL07jJyeRtKF3NFPaX0HAbEJi PmdA== X-Gm-Message-State: ACrzQf0ZvXC03w2sy5/SXmOWr2L6Xm/5JpozfHnSO8K7r+WrG2t3Ttxl cFcJok3yDMNLjPuhwCz6ZrPDzu6QoSsD06iVzgnH41h1Qd4LiGmYACHGlol3S99j1c4TeibqdRT glYrjepmpVkbzgHVgjEbJjjcEh7qrVj86wxA8jBQmaMFzpHWolRDgLVbfCmWxkZSC8i6VoGg= X-Google-Smtp-Source: AMsMyM4HdAPt49plfVhTqKf/uwC3pV1pQZO/7JKgk/vNwlIJS5eBvF0b3AvM2CEnevlLPdmOJ+NdHdq4b4DC X-Received: from jstultz-noogler2.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:600]) (user=jstultz job=sendgmr) by 2002:a17:902:d2d2:b0:177:4940:cc0f with SMTP id n18-20020a170902d2d200b001774940cc0fmr2371872plc.4.1663723556992; Tue, 20 Sep 2022 18:25:56 -0700 (PDT) Date: Wed, 21 Sep 2022 01:25:48 +0000 In-Reply-To: <20220921012550.3288570-1-jstultz@google.com> Mime-Version: 1.0 References: <20220921012550.3288570-1-jstultz@google.com> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog Message-ID: <20220921012550.3288570-2-jstultz@google.com> Subject: [RFC PATCH v3 1/3] softirq: Add generic accessor to percpu softirq_pending data From: John Stultz To: LKML Cc: John Stultz , John Dias , "Connor O'Brien" , Rick Yiu , John Kacur , Qais Yousef , Chris Redpath , Abhijeet Dharmapurikar , Peter Zijlstra , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Thomas Gleixner , Heiko Carstens , Vasily Gorbik , kernel-team@android.com, kernel test robot Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In a previous iteration of this patch series, I was checking: per_cpu(irq_stat, cpu).__softirq_pending which resulted in build errors on s390. This patch tries to create a generic accessor to this percpu softirq_pending data. This interface is inherently racy as its reading percpu data without a lock. However, being able to peek at the softirq pending data allows us to make better decisions about rt task placement vs just ignoring it. On s390 this call returns 0, which maybe isn't ideal but results in no functional change from what we do now. Feedback or suggestions for better approach here would be welcome! Cc: John Dias Cc: Connor O'Brien Cc: Rick Yiu Cc: John Kacur Cc: Qais Yousef Cc: Chris Redpath Cc: Abhijeet Dharmapurikar Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Thomas Gleixner Cc: Heiko Carstens Cc: Vasily Gorbik Cc: kernel-team@android.com Reported-by: kernel test robot Signed-off-by: John Stultz --- arch/s390/include/asm/hardirq.h | 6 ++++++ include/linux/interrupt.h | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/arch/s390/include/asm/hardirq.h b/arch/s390/include/asm/hardir= q.h index 58668ffb5488..cd9cc11588ab 100644 --- a/arch/s390/include/asm/hardirq.h +++ b/arch/s390/include/asm/hardirq.h @@ -16,6 +16,12 @@ #define local_softirq_pending() (S390_lowcore.softirq_pending) #define set_softirq_pending(x) (S390_lowcore.softirq_pending =3D (x)) #define or_softirq_pending(x) (S390_lowcore.softirq_pending |=3D (x)) +/* + * Not sure what the right thing is here for s390, + * but returning 0 will result in no logical change + * from what happens now + */ +#define __cpu_softirq_pending(x) (0) =20 #define __ARCH_IRQ_STAT #define __ARCH_IRQ_EXIT_IRQS_DISABLED diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index a92bce40b04b..a749a8663841 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -527,6 +527,17 @@ DECLARE_STATIC_KEY_FALSE(force_irqthreads_key); #define set_softirq_pending(x) (__this_cpu_write(local_softirq_pending_ref= , (x))) #define or_softirq_pending(x) (__this_cpu_or(local_softirq_pending_ref, (x= ))) =20 +/** + * __cpu_softirq_pending() - Checks to see if softirq is pending on a cpu + * + * This helper is inherently racy, as we're accessing per-cpu data w/o loc= ks. + * But peeking at the flag can still be useful when deciding where to plac= e a + * task. + */ +static inline u32 __cpu_softirq_pending(int cpu) +{ + return (u32)per_cpu(local_softirq_pending_ref, cpu); +} #endif /* local_softirq_pending */ =20 /* Some architectures might implement lazy enabling/disabling of --=20 2.37.3.968.ga6b4b080e4-goog