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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2467C433FE for ; Tue, 11 Oct 2022 12:59:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229890AbiJKM7y (ORCPT ); Tue, 11 Oct 2022 08:59:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229887AbiJKM7o (ORCPT ); Tue, 11 Oct 2022 08:59:44 -0400 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAEFAE21; Tue, 11 Oct 2022 05:59:39 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4MmwmJ2DlBz6Pq81; Tue, 11 Oct 2022 20:57:20 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP4 (Coremail) with SMTP id gCh0CgD39si2aEVjv75sAA--.42468S3; Tue, 11 Oct 2022 20:59:35 +0800 (CST) Subject: Re: [PATCH] block: put the reference of the io scheduler module after switching back To: Yu Kuai , Jinlong Chen , axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, "yukuai (C)" References: From: Yu Kuai Message-ID: <7f6cb343-bf97-c73a-c3da-c22d7543bd4a@huaweicloud.com> Date: Tue, 11 Oct 2022 20:59:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TR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Za9 -UUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! 在 2022/10/11 20:54, Yu Kuai 写道: > Hi! > > 在 2022/10/11 18:21, Jinlong Chen 写道: >> We got a reference of the io scheduler module in >> blk_mq_elv_switch_none to prevent the module from >> being removed. We need to put that reference back >> once we are done. > > However, if blk_mq_elv_switch_none() failed due to OOM, and module > reference is not acquired, blk_mq_elv_switch_back() will still be > called. This seems not to be the right fix. Please ignore this. I got it now if switch none failed, old queue is not added to the list, and later blk_lookup_qe_pair() will fail to lookup the queue. Thanks, Kuai > > Thanks, > Kuai >> >> Signed-off-by: Jinlong Chen >> --- >>   block/blk-mq.c | 7 +++++++ >>   1 file changed, 7 insertions(+) >> >> diff --git a/block/blk-mq.c b/block/blk-mq.c >> index 8070b6c10e8d..8dfe3bf3e599 100644 >> --- a/block/blk-mq.c >> +++ b/block/blk-mq.c >> @@ -4595,6 +4595,13 @@ static void blk_mq_elv_switch_back(struct >> list_head *head, >>       mutex_lock(&q->sysfs_lock); >>       elevator_switch(q, t); >> +    /** >> +     * We got a reference of the io scheduler module in >> +     * blk_mq_elv_switch_none to prevent the module from >> +     * being removed. We need to put that reference back >> +     * once we are done. >> +     */ >> +    module_put(t->elevator_owner); >>       mutex_unlock(&q->sysfs_lock); >>   } >> > > . >