Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1075062pxa; Wed, 12 Aug 2020 22:59:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8qNOM+h4v5PGrujJ8SKPkqKNn+uBk5e5O8N7bZYE/wiD5vqZ5y0J7NCHALD5qv7NUSNk4 X-Received: by 2002:a17:906:7b83:: with SMTP id s3mr1866621ejo.2.1597298381392; Wed, 12 Aug 2020 22:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597298381; cv=none; d=google.com; s=arc-20160816; b=lOtOoW6azCzBlTL1idrqaHc2ioywd2jjx55z8lzvC1P///FGV2+BazWNZHAanFs/Kp 3fZrYtmq+EnBnmnjwcdxe2LNHT+dmesHlFrIKVYfEM57btCGu2+NTgnzzQWnS3pymYn6 XEHvLTqsEOOPJ0Os4+hNHva6JpFM/x9tzxSSjxpuVn4wlci//6SVnk5ABE2afCTnBZk/ UmREX71NwRzFUWDuVo74eQfZFMBSjFhr2jS7cDn03Itfdpk/FEr3Z7E2+4yE9+G9WbiF Av4X4vfkPF/YDY3XfUExXmUJGazlmzKd3gwmwb45aSBS1CNdrbcCZx5gxIWbTF8oETqY HgNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=A2tIL3lRKqt3QhjARTkmfIICANxslC8SgzyYivoY1jI=; b=g28rsU/beFgDt0zDM+pn/+9WlfhknBClSzgiMYhgpJnI3Er8TBCW9uLXn90Iibgxb1 82KyKArlhzikD3yQOJXHd5k6Hzf8ZCR0yqmFRFWhjblhUocnk7vqrVu5z95E43TW3idH rR9HdXBC8P/6u0gT2t0gqlv4SfQ32ffugVrIo765O4Lt7MGZLGyFpbt0Gf7dgzGARlfn I13DlC5PR32ypVTBMmWaYOjlTsRSBffYPUxVbzxJuyXhn3ukVC5XOUXUSWqGe2MFaL/Z scA19O7omzAAg5laqFfSo7cE9f96ut15tOltvOV3GnLr8fIm9+t7KG/pEMTdbC1myl61 Q17A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=esifnW1s; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a25si2984370edn.30.2020.08.12.22.59.18; Wed, 12 Aug 2020 22:59:41 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=esifnW1s; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726499AbgHMF6h (ORCPT + 99 others); Thu, 13 Aug 2020 01:58:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725954AbgHMF6h (ORCPT ); Thu, 13 Aug 2020 01:58:37 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC14CC061757; Wed, 12 Aug 2020 22:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=A2tIL3lRKqt3QhjARTkmfIICANxslC8SgzyYivoY1jI=; b=esifnW1ssdRYcS8qFCosQ3I/yv b/byejn2cSb+i3bwvW+nJbT8jThfqBrPUol4ISi7/M8kQ9FqIAH9blMrJZFsCYbPrg9DSYojg8EV+ xSfG+zzUy7qo2QHi91KM3vmNAs/EAHLychpHou7Tl38bA5ym+Hwf9VHmpTVnNS+LXWT8SMm+FYLOJ vhWStCFq1L6Auyv+P4mAp9j+7w44JNc82kI1yZcqCVuvmz690fma3Dnmr2omi+PaG1ISpjis60MdN GPJps4VefW5qGIqKDCrSTiQ8rBmTi4ZV/PfbWP3clFuB+RnlDdAbbymiIEYoASiMb7UeT6uuS6U6w BMVN/uoA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k66Fr-000368-Uc; Thu, 13 Aug 2020 05:58:24 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 3C7BB980C8B; Thu, 13 Aug 2020 07:58:22 +0200 (CEST) Date: Thu, 13 Aug 2020 07:58:22 +0200 From: Peter Zijlstra To: Jiafei Pan Cc: mingo@kernel.org, tglx@linutronix.de, rostedt@goodmis.org, romain.perier@gmail.com, will@kernel.org, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, leoyang.li@nxp.com, vladimir.oltean@nxp.com Subject: Re: [PATCH] softirq: add irq off checking for __raise_softirq_irqoff Message-ID: <20200813055822.GC3982@worktop.programming.kicks-ass.net> References: <20200806040729.39186-1-Jiafei.Pan@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200806040729.39186-1-Jiafei.Pan@nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 06, 2020 at 12:07:29PM +0800, Jiafei Pan wrote: > __raise_softirq_irqoff will update per-CPU mask of pending softirqs, > it need to be called in irq disabled context in order to keep it atomic > operation, otherwise it will be interrupted by hardware interrupt, > and per-CPU softirqs pending mask will be corrupted, the result is > there will be unexpected issue, for example hrtimer soft irq will > be losed and soft hrtimer will never be expire and handled. > > Adding irqs disabled checking here to provide warning in irqs enabled > context. > > Signed-off-by: Jiafei Pan > --- > kernel/softirq.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/kernel/softirq.c b/kernel/softirq.c > index bf88d7f62433..11f61e54a3ae 100644 > --- a/kernel/softirq.c > +++ b/kernel/softirq.c > @@ -481,6 +481,11 @@ void raise_softirq(unsigned int nr) > > void __raise_softirq_irqoff(unsigned int nr) > { > + /* This function can only be called in irq disabled context, > + * otherwise or_softirq_pending will be interrupted by hardware > + * interrupt, so that there will be unexpected issue. > + */ Comment style is wrong, also I'm not sure the comment is really helpfull. > + WARN_ON_ONCE(!irqs_disabled()); lockdep_assert_irqs_disabled(); > trace_softirq_raise(nr); > or_softirq_pending(1UL << nr); > }