Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4024081pxb; Tue, 2 Nov 2021 02:43:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzcDVTNRavoMS+d+TSl9v38TLuzyFdxIc/ehGkgQI096pE7SofDP4aomlImkXS4NQq0Zwt X-Received: by 2002:a05:6602:2244:: with SMTP id o4mr24993963ioo.115.1635846186214; Tue, 02 Nov 2021 02:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635846186; cv=none; d=google.com; s=arc-20160816; b=fxyZpe137dsV9q1Suaiwu+7Peg4iODtqS1XozQbwii4LD7xVgxqjCsZrd7UVm+jwbD syaiajv8Zq8P8W0cAUWy7B1rdQoqqf17+2EUO1lX70ARkvjaSZkGqLOzxCfbN1LNVyro 7lGkBmRM4+IsBnEN9drXGOjSlgx4BDMmleATdMEy5Buc/2pxtZTEstcMSfTlBFkONyup EIS6XPkdNPeaO3fK9XNrncVJfgNcCpR2PZgbphY/xA9TYYO+H3kgyFfHbAaDQArBSLLA IcBY2ev1hBafvz0P2sqTVs4+sLSBzUHjg+CyJ7XEkyoNCRP1fd8lM3f8pgKMI9c6afwb ucKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=ZW+8O4s0rJ1wYpYQ/yCPUQIYSI2PgmRKLIuSTxGkos4=; b=fji2jPdMR4A1BxHTMQntD1KU3rkftOGADqoLfD69Ui30f7EOy1+Be6cNAR0qXjVIES 9PQZrwMz0gKdTvxRlCJdWIyL6ci5C5F8BSbFGm11PZ+PKDZvehvxRXVagflwlemcD3Hr 7onGQKokfEifWUymrbpDYiocT7qbAt0dGwikHpKqCNmCMsLgaGRAm92hAhfXwfw8czxy 85NqcA6pcchadEzgNFB/8iHVvbGson1t+gt13/h/w2xOjI1AOYwOIYuYWnnnyMhQ87n0 2baOLfID1V33xWkloKo8XZxbuC4DkmxYN46PitaYskxa2zefSMKKouqSVkJqju+cvyGp xxvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=N3sCvzxn; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si7418303jap.105.2021.11.02.02.42.55; Tue, 02 Nov 2021 02:43:06 -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=@gmail.com header.s=20210112 header.b=N3sCvzxn; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229778AbhKBJog (ORCPT + 99 others); Tue, 2 Nov 2021 05:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbhKBJog (ORCPT ); Tue, 2 Nov 2021 05:44:36 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B7C4C061714 for ; Tue, 2 Nov 2021 02:42:01 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id k4so5359056plx.8 for ; Tue, 02 Nov 2021 02:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=ZW+8O4s0rJ1wYpYQ/yCPUQIYSI2PgmRKLIuSTxGkos4=; b=N3sCvzxnUT9zaeiJElQoQrxkV2YKMetiR5J3Ix3oFsFtSTdlRi4sy5Bdj+huJwEWIJ TdKK6YyM4lWcmvbAvWA0AA6GfoLPO7YJ4Xk7FvAAE3lmmGj4uZtazBOf32DaP7fSouYh bPkB7AzIlU0OUNHBJUphmDSkatjarUgKyBRefa6yzXemWCQEhLw2NFdG5XkOcSEyE7tZ rYhPWFEFv77kHDyrbROdI3KJCEq+T8L5sljgE2ChcmoAtNDdQioxbRZ1FaCPjprHBOdv dxYbm1FKxpSTNj661BzXgT5L/uoVFWtW/1wtPcD1F268njQwo1FRMlK8ngggHa8DlFYC TP4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=ZW+8O4s0rJ1wYpYQ/yCPUQIYSI2PgmRKLIuSTxGkos4=; b=J8licBCqby4I2jokS1FjzXTWfywcOkli/Hya1lnIl+MihaEmmNSENW7ymYZUK2G7KU IG5uRu4U4kgEr28fipux2I09KqHefB6ytWcJcH1XIjlTGBR3jZ1LR358YZTAU21BKsJP 1NXCH47hNtsJKN8RxOF5J684VPuNA2nAbYyFqxLLmInRyyRblskClDAQPRJ6eTByvRyZ g2warVzcTWcZb2yqaePT+baCb3oL8idPTiRg2b2UwgwhAkOQoGOzbLfW2PluH+gUk3nk 6SjXGh+8VJ5BYGQbUqqAe1ppF1h+ZKf2n79pXR3MxT7+urzGPbP0GnzfXN929HCEAbzC S9QQ== X-Gm-Message-State: AOAM533BQ79yMp0npgCqdHNLu9u8fdD59jJ6kbQExyPS2uxtK3yLOg4X xMTcmt9C5eJZ4/a39lWPW93iDxJcuCMZ2w== X-Received: by 2002:a17:90a:6e41:: with SMTP id s1mr3838341pjm.166.1635846120628; Tue, 02 Nov 2021 02:42:00 -0700 (PDT) Received: from [172.18.2.138] ([137.59.101.13]) by smtp.gmail.com with ESMTPSA id m22sm17957193pfo.71.2021.11.02.02.41.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Nov 2021 02:42:00 -0700 (PDT) Subject: Re: [PATCH] ALSA: seq: Fix RCU stall in snd_seq_write() To: Takashi Iwai Cc: tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org References: <20211102033222.3849-1-qiang.zhang1211@gmail.com> From: Zqiang Message-ID: <2d05ceab-b8b7-0c7b-f847-69950c6db14e@gmail.com> Date: Tue, 2 Nov 2021 17:41:57 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/11/2 下午4:33, Takashi Iwai wrote: > 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... I did not find useful information from the log,  through calltrace, I guess it may be triggered by the long cycle time, which caused the static state of the RCU to not be reported in time. I ignore the atomic parameter check,  I will resend v2 .   in no-atomic context, we can insert cond_resched() to avoid this situation, but in atomic context, the RCU stall maybe still trigger. thanks Zqiang > > > thanks, > > Takashi