Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3969488pxb; Tue, 2 Nov 2021 01:35:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCnjxxn5Ar8EmSpZYVKHc7ZLwcTtukBO8yj/I1dCriYe7WvI9OamFQYvmpEYfcI3ghoqhI X-Received: by 2002:a02:a50c:: with SMTP id e12mr1186291jam.29.1635842105733; Tue, 02 Nov 2021 01:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635842105; cv=none; d=google.com; s=arc-20160816; b=G5c6ogTlRfEvK/dHujMB914hdCHc6pFFLswz38RHu7W9zRnRf8wgDOablp3lvjXrcK 2Y7ac22AVhytpVMIklzVTor7ZcDEMsHGeSaXE3iyahok1GXQLagpcdWOWhTU9xpjiW+E YJb8FhcBZHHlOpnwiUFH0203MD8B84KIF2Punw27YlyrXssJUQtw2c/5vOKOV1DEzQH6 mkYr9hmsk6JTNlIVDdQyBtsBbvO7eWLLDOMr4RuMUAlAlwsU21Hp9k7Qu++oJNLB91HO 7EgnoARzwH2NUZmT0pdIXul2qAg82UejzbjwBn5nQuAaWoeJl8q6Ek/gUWL2Zx+tIzRY dXXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=t2IT/o+8Ln8itaqpCquNFH+qyCEqcX9y1LvXTcQoBW0=; b=NkNJY468kSrYyne2NeDqw/I8YahpTdhU2nRtMEbXbHN/nHsIS0/IxCqJo8Hg46aNbV waZL7le5tWC+cvEeDMJFnrkCaoaBdM9d/sgwhpNtm9wJjxfbmqHlTNohN6L0l0Iln5kj rOPbZ/NFWyQPDz+OaWkK3PUbkC0iwpEEEIQTA+QwoZxEsf6n07iCYrKadPUB8llhAEk2 JV4fGeX4D5uFMUxbISqrORshig22sD/dhzq5ELYAkEltKiY61pi8tHqR8BouVQMEyeOQ 20aGQQBv62/1kQx//sPz8p1IlQaO/hWS8tZLTEc+vwkmlWoa9MIdeelfLvQ4PFyZdp3M mw1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=eUXKYKr3; dkim=neutral (no key) header.i=@suse.de; 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=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si20948629iop.36.2021.11.02.01.34.52; Tue, 02 Nov 2021 01:35:05 -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=@suse.de header.s=susede2_rsa header.b=eUXKYKr3; dkim=neutral (no key) header.i=@suse.de; 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=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbhKBIgN (ORCPT + 99 others); Tue, 2 Nov 2021 04:36:13 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:48212 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbhKBIgM (ORCPT ); Tue, 2 Nov 2021 04:36:12 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 1A8D91FD77; Tue, 2 Nov 2021 08:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1635842017; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=t2IT/o+8Ln8itaqpCquNFH+qyCEqcX9y1LvXTcQoBW0=; b=eUXKYKr3qhTxI6MybOhhgYX54RUP4tVin8j26AUUHBl12XiCLdOVH0yOzH+NmuYfgQ02uy f4PkPrbtuND9wIxHXljEYaXzkzOhBftSBGBcARgbgMI6z23E6COsu/L+XJt4Qss6gCnd7a /v1GAo+WcXnX/L4ASXkA8fiQocwc9dE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1635842017; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=t2IT/o+8Ln8itaqpCquNFH+qyCEqcX9y1LvXTcQoBW0=; b=bwE+Gm2ya5r4gt++cvcXJ9lGHoKXmYofMipVBsxgzusZ71d0Yl+19UUqMISa79TpKLi/DW XhWMwxP7PKwg1OCQ== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 0336CA3B84; Tue, 2 Nov 2021 08:33:37 +0000 (UTC) Date: Tue, 02 Nov 2021 09:33:36 +0100 Message-ID: From: Takashi Iwai To: Zqiang Cc: tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: seq: Fix RCU stall in snd_seq_write() In-Reply-To: <20211102033222.3849-1-qiang.zhang1211@gmail.com> References: <20211102033222.3849-1-qiang.zhang1211@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 02 Nov 2021 04:32:22 +0100, Zqiang wrote: > > If we have a lot of cell object, this cycle may take a long time, and > trigger RCU stall. insert a conditional reschedule point to fix it. > > rcu: INFO: rcu_preempt self-detected stall on CPU > rcu: 1-....: (1 GPs behind) idle=9f5/1/0x4000000000000000 > softirq=16474/16475 fqs=4916 > (t=10500 jiffies g=19249 q=192515) > NMI backtrace for cpu 1 > ...... > asm_sysvec_apic_timer_interrupt > RIP: 0010:_raw_spin_unlock_irqrestore+0x38/0x70 > spin_unlock_irqrestore > snd_seq_prioq_cell_out+0x1dc/0x360 > snd_seq_check_queue+0x1a6/0x3f0 > snd_seq_enqueue_event+0x1ed/0x3e0 > snd_seq_client_enqueue_event.constprop.0+0x19a/0x3c0 > snd_seq_write+0x2db/0x510 > vfs_write+0x1c4/0x900 > ksys_write+0x171/0x1d0 > do_syscall_64+0x35/0xb0 > > Reported-by: syzbot+bb950e68b400ab4f65f8@syzkaller.appspotmail.com > Signed-off-by: Zqiang > --- > sound/core/seq/seq_queue.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c > index d6c02dea976c..f5b1e4562a64 100644 > --- a/sound/core/seq/seq_queue.c > +++ b/sound/core/seq/seq_queue.c > @@ -263,6 +263,7 @@ void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop) > if (!cell) > break; > snd_seq_dispatch_event(cell, atomic, hop); > + cond_resched(); > } > > /* Process time queue... */ > @@ -272,6 +273,7 @@ void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop) > if (!cell) > break; > snd_seq_dispatch_event(cell, atomic, hop); > + cond_resched(); It's good to have cond_resched() in those places but it must be done more carefully, as the code path may be called from the non-atomic context, too. That is, it must have a check of atomic argument, and cond_resched() is applied only when atomic==false. But I still wonder how this gets a RCU stall out of sudden. Looking through https://syzkaller.appspot.com/bug?extid=bb950e68b400ab4f65f8 it's triggered by many cases since the end of September... thanks, Takashi