Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp76874lqd; Tue, 23 Apr 2024 15:28:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXBgEMY5cqhjyqoXPxKwhlWfKh4rWER3rslBwVjGI5JbRgr8WfnCkuUipuvupN9dwVbf7cjdlBlvy9ovSgJMwp9ZTOyrCeCJEw92FWHcA== X-Google-Smtp-Source: AGHT+IGU2vVnzEVumZ+Jsqkkq1AMkjtRbDVNKD2MIJEe4TF5oW87QflzskbONmDgPxn/AiLHYkX1 X-Received: by 2002:a05:622a:547:b0:43a:160e:4f75 with SMTP id m7-20020a05622a054700b0043a160e4f75mr633879qtx.53.1713911337781; Tue, 23 Apr 2024 15:28:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713911337; cv=pass; d=google.com; s=arc-20160816; b=Off1ULMqVoJXq2kQKU8qMyGhtM8oKmi9xIVwS7bnq6PgVvWIf8+sIDmTLmk6cavh+9 kdfgHwgBO4lrH0hvdAlcbOn83BLN41d/gfHqVu0FC36snL68F+C++Gd4yAp/oVYAsR2O qZpfSywvqaHYmL8GPbkk5QvxxUGEv1Tkg0SYjH0iZFpOVjwSKPlTP4a07cO5Y3gCB0Nv 6oIdAFfz1EnrHMPSOVqTI8d+/EIpkFA/1ZA6fMyhTo3B/3cJTkDhewgIamoPE0PBmoRW Q2DiuZ4opMiOGYib77ddgTcJqpkLneqlAwrV8uw/Sy5tkLYplyfES1YM0w5vq1CgBgfM jJCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=R6yKv4zzKIXsa4AbK3JYXZ64KnUbWE67ow2SNxhxnM0=; fh=NbJLV8lXBg3RgjvGoGPn5I+gOJ5PXkNm0MIKp5XF9pI=; b=Pja0wzrUFKMhbN3V3V1sLRoQHQzepe/Ki38tmHhF36Y/qCsoI+qquE+ZgLLmYVH/qV XGSFDhBpvzigW/+fNgaLFcr6gLCKXYEZ+aDwJ4/XJM4MzPY+6gLKq2bv8OJz1UpVA8Ri 8GbYHJxEX5DZPnxgvY5jGcfhajK5mpp4Usbwv3+G8W1AI4Y3rrh68qZ7z+/3NBhnPvD+ gl3vyf9uNEPQkiGC7vsW4JfIIMVfCLqPmu3auVOd/PvYlOpEcpqOvej1jCB16+V35RzW gTaEbIKHTzgikWX6MIVFUJVDZczyxCAS+shEvbBZxI8CPe3xCtUCGsr78yIHpkqQyc6J yVWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="pT3cr/Bp"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-155956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155956-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f4-20020ac87f04000000b00437bec6d1e3si12373553qtk.213.2024.04.23.15.28.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:28:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="pT3cr/Bp"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-155956-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155956-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 83E721C21ACD for ; Tue, 23 Apr 2024 22:28:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 65E1D143C45; Tue, 23 Apr 2024 22:28:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pT3cr/Bp" 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 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;