From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D97D85274 for ; Tue, 23 Apr 2024 22:28:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713911332; cv=none; b=P21nE1ekQ1/68HrYzvmt0TW53hNZAVKbO8r+LweZ86suY1T4qgKMnGfuE3LB+B+u50LuUB4cd2+hOYS8w/bf4UPaOjp3WDNOnlxooTYbmSzAupvtPbhnW70j7rO6SyR0A4XQpK4S796zrnqzWT3bS1TFr45mlue2M7cKN/EhOT8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713911332; c=relaxed/simple; bh=Smf0YUi9NGBseopnvhxZ9pzCNFEUTNZ5RF659bgElf4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XQ2Jh5lKU++OI0igsiCOzzRnvoAS/KWlYCn/xjxYEpRJRDGyjNZmWSz+WxvOpXqNPamwnlJfPNu/cP8Gh/HG6G5eSE9ANkm6qL9S5E/9ED7mIq53I86j7Fv2fLKVgvjW8pOevNBqPlCvpGPEoQM/uo69+pWSc3QlwhZ8FqBC9Oc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pT3cr/Bp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pT3cr/Bp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CC42C116B1; Tue, 23 Apr 2024 22:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713911332; bh=Smf0YUi9NGBseopnvhxZ9pzCNFEUTNZ5RF659bgElf4=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=pT3cr/BpI9fJXm4Qa832D0PSY/sgZxHItlthFSvHVDo1rjuvGzfnwSYjA8Lg860wH D8H/ZTKmsvNjx89M8WhajFkoUA4dzhIRRgpb4CljVuVHmWf5wjwuXec1al1RyjVon9 msADxm2hIpTFRIq/ojxxJzFz3Qv0Y78G8yH31Vtk5brOnAXIC1bw9J+b9IBmZ215Jx WGCQhdDvUG3epMw6VANYNSgJnMF1te9oCIdofr9+MOosLCfABOmOZlPqiESlMW8RWb jDvcuhbgA6LzuvrnbhvBywsG1eGeWDFahsgd0awSZdVQODOJ8EBetM/wpsc4N2IJxD mMdvK6T9krP8Q== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id A6590CE0962; Tue, 23 Apr 2024 15:28:51 -0700 (PDT) Date: Tue, 23 Apr 2024 15:28:51 -0700 From: "Paul E. McKenney" To: Z qiang Cc: Thomas Gleixner , syzbot , linux-kernel@vger.kernel.org, peterz@infradead.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [kernel?] WARNING: suspicious RCU usage in __do_softirq Message-ID: Reply-To: paulmck@kernel.org References: <8f281a10-b85a-4586-9586-5bbc12dc784f@paulmck-laptop> <4c09abb6-4f6e-42d7-9944-c5da995649cb@paulmck-laptop> <87o7a1umj3.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Apr 23, 2024 at 10:20:49AM +0800, Z qiang wrote: > > > > On Fri, Apr 19 2024 at 13:50, Z qiang wrote: > > >> On Thu, Apr 18, 2024 at 05:49:38PM +0800, Z qiang wrote: > > > static __init int spawn_ksoftirqd(void) > > > { > > > + int cpu; > > > + > > > + for_each_possible_cpu(cpu) > > > + per_cpu(ksoftirqd_work, cpu) = false; > > > > First of all that initialization is pointless, but why making all of > > this complex as hell? > > > > Thanks, > > > > tglx > > --- > > diff --git a/kernel/softirq.c b/kernel/softirq.c > > index b315b21fb28c..e991d735be0d 100644 > > --- a/kernel/softirq.c > > +++ b/kernel/softirq.c > > @@ -508,7 +508,7 @@ static inline bool lockdep_softirq_start(void) { return false; } > > static inline void lockdep_softirq_end(bool in_hardirq) { } > > #endif > > > > -asmlinkage __visible void __softirq_entry __do_softirq(void) > > +static void handle_softirqs(bool kirqd) > > { > > unsigned long end = jiffies + MAX_SOFTIRQ_TIME; > > unsigned long old_flags = current->flags; > > @@ -563,8 +563,7 @@ asmlinkage __visible void __softirq_entry __do_softirq(void) > > pending >>= softirq_bit; > > } > > > > - if (!IS_ENABLED(CONFIG_PREEMPT_RT) && > > - __this_cpu_read(ksoftirqd) == current) > > + if (!IS_ENABLED(CONFIG_PREEMPT_RT) && kirqd) > > rcu_softirq_qs(); > > > > local_irq_disable(); > > @@ -584,6 +583,11 @@ asmlinkage __visible void __softirq_entry __do_softirq(void) > > current_restore_flags(old_flags, PF_MEMALLOC); > > } > > > > +asmlinkage __visible void __softirq_entry __do_softirq(void) > > +{ > > + handle_softirqs(false); > > +} > > + > > /** > > * irq_enter_rcu - Enter an interrupt context with RCU watching > > */ > > @@ -921,7 +925,7 @@ static void run_ksoftirqd(unsigned int cpu) > > * We can safely run softirq on inline stack, as we are not deep > > * in the task stack here. > > */ > > - __do_softirq(); > > + handle_softirqs(true); > > Thanks, this is good for me :), > Paul, what do you think? This looks quite nice to me, especially given that it avoids changing all the other calls to __do_softirq(). Some architectures might want to directly call handle_softirqs(), but if so, they can send the patches. Thanx, Paul > Thanks > Zqiang > > > ksoftirqd_run_end(); > > cond_resched(); > > return;