Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1062398pxa; Wed, 5 Aug 2020 21:21:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywSRFafIIs5utpSpYzlJdbXKlCzbcKg5aDHYMmu+VZetDqOKAjTBgQ1m/AiDEBwmJ/Zw6c X-Received: by 2002:aa7:ccd5:: with SMTP id y21mr2219486edt.91.1596687685577; Wed, 05 Aug 2020 21:21:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596687685; cv=none; d=google.com; s=arc-20160816; b=fPsb7UtL+C6CLmp6hkpGwHW8YcSCTiXhGDXWkfIwPc/Oo5va4j3aWT47ltYHA8A/zl /g5uN04X7L3RJdTrCeXVtpI/Ok/01dO7pdMQASXDHdKyGL5c/hrVsY4VaY4pia32dtsv 1HiYGmoaVeDahqUBiY/oephglzE6z224+lQwahWOdPTTHAK0dTHRLQOi59vI67WmE8RF wlohr7dDewi6EHnikaBjwqKe9KjjQoTNDXPu5LqP+peQoZt5i241EISlXtkVgv0ViKbi 2sMNjTqfWsiEc0/iIozj00iyXdROm7t7cKuYFPAwQqvhaGgYLhCu0pePOYf6nnc19Cwn FuIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=zJfna8RXZfGlbMUCXewEr5FTAuw1OL+uYD6sY1GcnL8=; b=NXgGknHIslsckgcNp4uyFYiId9n84mGwK7nkTV7NrT7cUKTiDGq7bGASKp7FoqOuxP jDczRWG7N3vbtnerBDcOEC5EQiNJcKq8Spnc++VFLVw31iCqrwT48GWDZhg5VWOSR8SM dp176I6iLgHCEC/2c62D1FENwVgYgCyXakbwxuaVpO1fFfVYMRPGMd48BQyjcTruBUQw chpM6OAXFcH/2UUrs03FbNDSaTtD7PEMLKrbwZVMN6wfGN8HWL54XDAHNwgQHb9OoqXy 4Wo++n3Wp3IZLn4O+6B7XlCmuTzadnnqLBpjI3e7CiBiC+/zXwfwS08DM/mMVrt8Z5OX rNQQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rl4si2627891ejb.648.2020.08.05.21.21.02; Wed, 05 Aug 2020 21:21:25 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727053AbgHFEOq (ORCPT + 99 others); Thu, 6 Aug 2020 00:14:46 -0400 Received: from inva021.nxp.com ([92.121.34.21]:38082 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726159AbgHFEOo (ORCPT ); Thu, 6 Aug 2020 00:14:44 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 5ABBD200764; Thu, 6 Aug 2020 06:14:42 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 6A77220074E; Thu, 6 Aug 2020 06:14:37 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id B13714032D; Thu, 6 Aug 2020 06:14:31 +0200 (CEST) From: Jiafei Pan To: peterz@infradead.org, mingo@kernel.org, tglx@linutronix.de, rostedt@goodmis.org, romain.perier@gmail.com, will@kernel.org Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, jiafei.pan@nxp.com, leoyang.li@nxp.com, vladimir.oltean@nxp.com, Jiafei Pan Subject: [PATCH] softirq: add irq off checking for __raise_softirq_irqoff Date: Thu, 6 Aug 2020 12:07:29 +0800 Message-Id: <20200806040729.39186-1-Jiafei.Pan@nxp.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __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. + */ + WARN_ON_ONCE(!irqs_disabled()); trace_softirq_raise(nr); or_softirq_pending(1UL << nr); } -- 2.17.1