Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1715614rwr; Fri, 28 Apr 2023 00:18:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ74PM55cD6EWHBZPqIhvI9zlAgXtvzMavs47oKzmoxsbgsk5mViSsY6DMpXKJhtm/y38cy+ X-Received: by 2002:a05:6a00:1493:b0:63d:3411:f9e3 with SMTP id v19-20020a056a00149300b0063d3411f9e3mr7013767pfu.19.1682666313716; Fri, 28 Apr 2023 00:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682666313; cv=none; d=google.com; s=arc-20160816; b=v62fS1wNmhEdHcSqdsKpdMJpaZVnvOxeHP8tZCGh/hBm4ugxUIFBYtCAI2Yu+f5i9u f3pc+ZFZAvzlGpePCl9Uj/fBugll94Ybg16UtfBQHUtpdPTe+u6+f0ZZZcXvDkkXenU5 1vRQ8jfu/s6fET6rlJYZEL+zvRueb+Q2yGiKwgbbIOrD6ZqHL9M7ZJG4ArKHOppw06W3 eKYXZQXNd1LMQ9UqdxDbtjwVRnL1+xxmwYWffG7KhOhj5+VXs0jbyEzGpNuHcpY+hRsH fyqbUoCwxBucODqv8r+kpXDH3AvCh4+NAJreW0spT21xjyNFztkWcsFDVHQXHenhfK9s SHiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zKGazr2eK/2SMNzCISQrpbWn4hqLGG9X4u1zqfd7Sns=; b=hnBdoASuzwwrWYCj67M3ZBnH6Dy85gDp0p49D8DSBsCr1+n7hqcvREXw7bG3p+v8hU 8p3xm8We88ke1ESr9vdGnXAr/hm8oOnT+w28BAF+1/+z1b3Tx8AnoaLc4q5NNsrOAgek z3NPLbehDqbZyvntP4EmZBgy4sJVg6c24KtUiz/Grjo8kaebKypDYK+vqY/RwQ/3spBW ImdkvPfx9ea6nqzoie/5PoDE4CcHKdDBHu1E+Rr2yr9qx9KKTyJYZaAgVBrNLhfvhGBE LeSYFUFSqGQJ4exH/tW2BMHF2SotyOWUFxKVR7hGyg8MXp5zKdj1/waWyLe6VjP7rofD kI+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KoQKVBPp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g17-20020aa79dd1000000b0063b82925d69si20421323pfq.337.2023.04.28.00.18.22; Fri, 28 Apr 2023 00:18:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KoQKVBPp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345364AbjD1Gvj (ORCPT + 99 others); Fri, 28 Apr 2023 02:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345285AbjD1Gvh (ORCPT ); Fri, 28 Apr 2023 02:51:37 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CA2D30E8; Thu, 27 Apr 2023 23:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682664693; x=1714200693; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=aB2YsP1K3RdhXZS8cylTDflNzVA0nU4HK1q9q5xhY3s=; b=KoQKVBPpfgizayAK6YpfB0D9GZGS5gBSbkpXj6PtvEE7O/GDKTvXbRd9 dKmdQuiPS5FCtcjmhZ/yqwpmj+5iiw04twk65XdJfEf03jkmXf1S/YsZt Sza5kEWPGIYbd66QaVPsX/2rO221V2pW0FySdIe/CRIbaWFoT2K4Bf2rZ Ip0cR6tUT1GNyUrs98hU0MrkVHexexQ0u8YlRFqCeKdwNCQJPJxvJrwIK eayNzUyq7NC/ymYfY9b83CVAXCtrq36cupeiZzlT8gPPEC+DHdvCR4r2O YwmrFCmMb3z7LAo+qzr2OmKP4GwCoZXOYV7WJDTKOD7730y+KsR2GDtfs g==; X-IronPort-AV: E=McAfee;i="6600,9927,10693"; a="347694937" X-IronPort-AV: E=Sophos;i="5.99,233,1677571200"; d="scan'208";a="347694937" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2023 23:51:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10693"; a="644999650" X-IronPort-AV: E=Sophos;i="5.99,233,1677571200"; d="scan'208";a="644999650" Received: from linux.bj.intel.com ([10.238.156.127]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2023 23:51:30 -0700 Date: Fri, 28 Apr 2023 14:49:53 +0800 From: Tao Su To: Yu Kuai Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, tj@kernel.org, josef@toxicpanda.com, axboe@kernel.dk, "yukuai (C)" Subject: Re: [PATCH v2] block: Skip destroyed blkg when restart in blkg_destroy_all() Message-ID: References: <20230428045149.1310073-1-tao1.su@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 28, 2023 at 02:12:06PM +0800, Yu Kuai wrote: > Hi, > > 在 2023/04/28 12:51, Tao Su 写道: > > Kernel hang in blkg_destroy_all() when total blkg greater than > > BLKG_DESTROY_BATCH_SIZE, because of not removing destroyed blkg in > > blkg_list. So the size of blkg_list is same after destroying a > > batch of blkg, and the infinite 'restart' occurs. > > > > Since blkg should stay on the queue list until blkg_free_workfn(), > > skip destroyed blkg when restart a new round, which will solve this > > kernel hang issue and satisfy the previous will to restart. > > Please add a fix tag: > > Fixes: f1c006f1c685 ("blk-cgroup: synchronize pd_free_fn() from > blkg_free_workfn() and blkcg_deactivate_policy()") > > > > Reported-by: Xiangfei Ma > > Tested-by: Xiangfei Ma > > Tested-by: Farrah Chen > > Signed-off-by: Yu Kuai > > You can remove this tag, and feel free to add: > > Suggested-and-reviewed-by: Yu Kuai Got it, thanks! Tao > > Thanks, > Kuai > > Signed-off-by: Tao Su > > --- > > v2: > > - change 'directly remove destroyed blkg' to 'skip destroyed blkg' > > > > v1: > > - https://lore.kernel.org/all/20230425075911.839539-1-tao1.su@linux.intel.com/ > > > > block/blk-cgroup.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c > > index bd50b55bdb61..75bad5d60c9f 100644 > > --- a/block/blk-cgroup.c > > +++ b/block/blk-cgroup.c > > @@ -528,6 +528,9 @@ static void blkg_destroy_all(struct gendisk *disk) > > list_for_each_entry_safe(blkg, n, &q->blkg_list, q_node) { > > struct blkcg *blkcg = blkg->blkcg; > > + if (hlist_unhashed(&blkg->blkcg_node)) > > + continue; > > + > > spin_lock(&blkcg->lock); > > blkg_destroy(blkg); > > spin_unlock(&blkcg->lock); > > >