From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3513DC433E0 for ; Thu, 28 Jan 2021 01:37:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D333164D99 for ; Thu, 28 Jan 2021 01:37:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231405AbhA1Bgx (ORCPT ); Wed, 27 Jan 2021 20:36:53 -0500 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:50690 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231181AbhA1BgW (ORCPT ); Wed, 27 Jan 2021 20:36:22 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0UN56c69_1611797735; Received: from 30.21.164.7(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0UN56c69_1611797735) by smtp.aliyun-inc.com(127.0.0.1); Thu, 28 Jan 2021 09:35:35 +0800 Subject: Re: [PATCH] blk-cgroup: Use cond_resched() when destroy blkgs To: Tejun Heo Cc: axboe@kernel.dk, joseph.qi@linux.alibaba.com, linux-block@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org References: <8f4fb91ced02e58ef425189c83214086f1154a0c.1611664710.git.baolin.wang@linux.alibaba.com> From: Baolin Wang Message-ID: Date: Thu, 28 Jan 2021 09:35:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tejun, > Hello, Baolin. > > On Tue, Jan 26, 2021 at 09:33:25PM +0800, Baolin Wang wrote: >> On !PREEMPT kernel, we can get below softlockup when doing stress >> testing with creating and destroying block cgroup repeatly. The >> reason is it may take a long time to acquire the queue's lock in >> the loop of blkcg_destroy_blkgs(), thus we can use cond_resched() >> instead of cpu_relax() to avoid this issue, since the >> blkcg_destroy_blkgs() is not called from atomic contexts. >> >> [ 4757.010308] watchdog: BUG: soft lockup - CPU#11 stuck for 94s! >> [ 4757.010698] Call trace: >> [ 4757.010700]  blkcg_destroy_blkgs+0x68/0x150 >> [ 4757.010701]  cgwb_release_workfn+0x104/0x158 >> [ 4757.010702]  process_one_work+0x1bc/0x3f0 >> [ 4757.010704]  worker_thread+0x164/0x468 >> [ 4757.010705]  kthread+0x108/0x138 >> >> Signed-off-by: Baolin Wang > > * Can you please add might_sleep() at the top of the function? Sure. > > * Given that the system can accumulate a huge number of blkgs in > pathological cases, I wonder whether a better way to go about it is > explicitly testing need_resched() on each loop and release locks and do > cond_resched() if true? Yes, sound better to to me and will update in next version. Thanks for your sugestion.