Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp95426pxb; Wed, 18 Aug 2021 17:00:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMBw1GPMplbM80kZ0OwtP1/XoxyuiFJlj2hFRhj4e6hRpUPoJoYAw9h4bfWr8My2a5haJU X-Received: by 2002:a05:6e02:ed1:: with SMTP id i17mr7855001ilk.272.1629331220687; Wed, 18 Aug 2021 17:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629331220; cv=none; d=google.com; s=arc-20160816; b=pFdrvg6JzCu66KzyjDzEuArUDMnruweluXv3AyeWNzsnUijj4kDmSNRaXj/CFGGKkX rBCZoMQfm/d9wkQ9KMjWfoTKUeLWG53cw8F25K7cZ+D+Va4boAlNdrpCy//DzwmWfHfo WvgYj98R7gWycSV4s8YiIXixiFsljzqI1+lYWLw26jIKivLhge5rA33ZXUK6GXzAsZqB W6HL6rUP+pQPxzNesjFWIJdPWNSBmNUIVEI2ykJjLpSmIiFlFJHTGmtIjDqN5QJPS18c pZFTdmBLMZLbKzcqMda389GzTnzIMMgFoizBhWpQR+jQwOIXwGEwbZvU83pSyYMLEUAg c3/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IeP832SJzqeVnjZ0PVnLToyHfJsIkOgVQujTdfwewaQ=; b=DyNuDTh1of44a+pDvk3vK0Tjd0kgwR3QwgJRTugvKOT+jat/ZlrogPh1BcG5ZIlRIu CWkoeSTQzaeYzOpWvw6XyNpEqc/dpxpzY73ZKiFSDhP6l2L7K23aq0Q1KYmWID8yBh/t 4GK5LPviZMLo529PzLcuQme8XaktfaR3n1ys6DQw5a5FMUuW5/FL8mR3ZW8QH6MWgAbT e08YEPnif5BzbcD4dC4AlN9g/JgxGWiybTYQOoaWqocQBqlPsNptT1IRyA9XTOdUATr/ jiTZwNrLkSkCPBmugHiAYOqT11xB4EjnKoRW414H79XBQBYxw/Gf9gI4SWTnHnEwwK1z D5Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HLvCFvJR; 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 b19si1177455jaq.82.2021.08.18.17.00.09; Wed, 18 Aug 2021 17:00:20 -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=HLvCFvJR; 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 S235191AbhHSAAA (ORCPT + 99 others); Wed, 18 Aug 2021 20:00:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234949AbhHRX76 (ORCPT ); Wed, 18 Aug 2021 19:59:58 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0014C061764; Wed, 18 Aug 2021 16:59:22 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id w6so2854983plg.9; Wed, 18 Aug 2021 16:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=IeP832SJzqeVnjZ0PVnLToyHfJsIkOgVQujTdfwewaQ=; b=HLvCFvJRIjjfuLDY2SGy0zjxO1rqlnS5OZVluJmJva8WUFGPnr1EArc6LykYJOVHK7 y3Hs14pTxjX3RqjaxWI1ZD7Dq6p0uYUjKNYgoJjmhVy4dXmanVOVeo+pA4mZgYoU3tLG Gt1NzLtKzwa8yM/xW3zTSvq5f322qSXxX8IkSYFnklyhfP7GDs4kRPyn26ahyR4eYnKt XxH1FP9J8ZwySSmXr4/FkuF6PeLumbkkCixFT3OKjXUYwWl8AcbTV1uEAlGlNwNowyHL rc8lt6do5MV5CBcYsYG2H5awZo6oTwpGiL3pWmzvFMW9B5+DcRpgbL1ImaUmW5aSuBq9 JPXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=IeP832SJzqeVnjZ0PVnLToyHfJsIkOgVQujTdfwewaQ=; b=DGmnU3NZP6yWRrLCO0KoUkDjBv48q4mGVbbzUQ9Nt2in+X2cjOCOhfL4F0zj4Nznf7 7C52ty9U33TACLsPQRLoKVDBT7t1L9RcKMFoef1cBOX8myBNxy0Mj5597b+6sKCTVxXa 5bg5igtuW0SydtcO1hjMSpRcHylHy3QsGg5N10UYSRp+OHzehtXoxNBufRfKUQf9awKE thX/Dft/sMynUTGLAmC86Z3RMh3OON3iJnggjDtLfzNojaYY5H/1owIa9+KYEPTzxc3q iUpKYYbiRPltD1r8OSgompzA2LL17NF9DW9lb8CVyKCviW04hodisOSuO7TjF6mzbd6w DX2g== X-Gm-Message-State: AOAM531tOzBl0bA4s7h5nRAXhJne0GxCKNSwlGYVysgHQE0txqljL4Kh ADUON9CpDhtdBGILEpgkqdA= X-Received: by 2002:a17:90a:2f88:: with SMTP id t8mr11919550pjd.2.1629331162314; Wed, 18 Aug 2021 16:59:22 -0700 (PDT) Received: from mail.google.com ([141.164.41.4]) by smtp.gmail.com with ESMTPSA id k25sm894131pfa.213.2021.08.18.16.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 16:59:21 -0700 (PDT) Date: Thu, 19 Aug 2021 07:59:16 +0800 From: Changbin Du To: Boqun Feng Cc: Changbin Du , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , "Paul E. McKenney" , Josh Triplett , Sergey Senozhatsky , linux-kernel@vger.kernel.org, rcu@vger.kernel.org Subject: Re: [PATCH] preempt: add in_serving_irq() and apply to rcutiny and vsprintf Message-ID: <20210818235916.l3zbdt5nli5j65xi@mail.google.com> References: <20210814014234.51395-1-changbin.du@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 17, 2021 at 12:03:16AM +0800, Boqun Feng wrote: > On Sat, Aug 14, 2021 at 09:42:34AM +0800, Changbin Du wrote: > > At some places we need to determine whether we're in nmi, hardirq or > > softirq context. This adds a macro in_serving_irq() as a shortcut for > > that. > > > > Meanwhile, apply this new macro to existing code in rcutiny and vsprintf. > > > > Signed-off-by: Changbin Du > > --- > > include/linux/preempt.h | 4 +++- > > include/linux/rcutiny.h | 3 +-- > > lib/vsprintf.c | 2 +- > > 3 files changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/include/linux/preempt.h b/include/linux/preempt.h > > index 9881eac0698f..9a1c924e2c6c 100644 > > --- a/include/linux/preempt.h > > +++ b/include/linux/preempt.h > > @@ -92,12 +92,14 @@ > > * in_nmi() - We're in NMI context > > * in_hardirq() - We're in hard IRQ context > > * in_serving_softirq() - We're in softirq context > > + * in_serving_irq() - We're in nmi, hardirq or softirq context > > * in_task() - We're in task context > > */ > > #define in_nmi() (nmi_count()) > > #define in_hardirq() (hardirq_count()) > > #define in_serving_softirq() (softirq_count() & SOFTIRQ_OFFSET) > > -#define in_task() (!(in_nmi() | in_hardirq() | in_serving_softirq())) > > +#define in_serving_irq() (in_nmi() | in_hardirq() | in_serving_softirq()) > > +#define in_task() (!in_serving_irq()) > > > > So in_serving_irq() is !in_task(), right? If so, why not... > Adding in_serving_irq() is to reflect the real purpose so improve readability. And can we preserve that !in_task() means in serving irq context in future? I don't know. -- Cheers, Changbin Du