Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp494967rdb; Sat, 19 Aug 2023 09:58:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSp06a+pTWEm+Zvh5olopQOPfL3mzMgRBA1cC38a+1xHWPJTt1te+T8di4KlnD6yhRSYj7 X-Received: by 2002:a17:90a:6e4b:b0:269:34a6:d4ca with SMTP id s11-20020a17090a6e4b00b0026934a6d4camr2208112pjm.0.1692464295137; Sat, 19 Aug 2023 09:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692464295; cv=none; d=google.com; s=arc-20160816; b=Tois7sMmNkdSgGkeBFC03NpVry/tY7GtYU65srRRI0DT6WdqjHwlQ1+FIqmDV56+AM WGuP8NNYufHWhOnpPDWJqUQta+L3a2MAguB6xXxcya1ePEOcQX2aFj4bLAuzWhQmBXbi zpzBSg3RmjtLuzYaBZbIzVQnb8XkPeSpDSnUnLqPAhqspE0mTetI7CXXyuE1hBy6z8r0 Hzg3BKUZIl/F/oR/13PUys7CgILpsmGUykk99TzwMApMOBPPG1sSYqAYg5vF6K1NlwHR a1GqTgLh12VRScgKBQQksIYcqVF11BuMfvNF+fKJjJ0o0x4tBl/zQ5zUJaocDY3gwgcH Y4+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=8vHHVkxWW04IoUZrYFRpOEcAsjjg8V3LWudLTC9GREA=; fh=vtllgLYKFKrNeOOxyM8340ejmDVF+AmGs5kAKjsav5c=; b=SNPESn2lhaco37Gn4bSuHJgjc34GseDbU07QCQRRzgE5KPpnaIahKIvGNezbQym0It 0MFgKATZSPPlPnjAVLmyV4z1+wjkNJ70zkuQ4Ye+FsfhUCwXe++U/W1qfPsjkySf49cH wehomCeZq8qW/VweQX1ct616sw0oV/8XnJhkb6TMqDBzOLwHavNfV2UDmZ3P7Spi/Kjh gj8imGgXGC9p6b3syNuxt16trHoHMeUnPoP4637YrZPOt0xEanhh7u3Jr9FrsnC8irVv 7w1XFoGCVbAzMuOJWCCU+y5xlmLppK8xIELRokwXmCPgZDcApWS6xK1qMI1pWXFBP/86 xDzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=QYVrl6Fu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h9-20020a17090a648900b00263eb5054f2si3764455pjj.105.2023.08.19.09.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 09:58:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20221208.gappssmtp.com header.s=20221208 header.b=QYVrl6Fu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 02869123756; Sat, 19 Aug 2023 01:53:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353959AbjHQRZA (ORCPT + 99 others); Thu, 17 Aug 2023 13:25:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353964AbjHQRYy (ORCPT ); Thu, 17 Aug 2023 13:24:54 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F084BD3 for ; Thu, 17 Aug 2023 10:24:52 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6889c748c44so5785b3a.0 for ; Thu, 17 Aug 2023 10:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20221208.gappssmtp.com; s=20221208; t=1692293092; x=1692897892; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=8vHHVkxWW04IoUZrYFRpOEcAsjjg8V3LWudLTC9GREA=; b=QYVrl6FujIq30u7lKbb0YTqb9pdMFvQv2J3WVa07YyWOZKIgoaBlzAvTb5pTrRVof8 cwaXMhFmAQivePfOEM2qJ1y8z0bqwqTpZht34ALsShKn9IuvFbFXCOzTBFla6NxdbKst BsKg5muo7QMuu7YzP4ETLd43HAQxN/vFhVEjAhdDzERTuWkPcuCYLgK4Llj7TR1TjTof Tgw/8zqqHFI+SSJ9G0N8nKDzsz/agYbRuCP3h53Ul7UwUO6DnIo7p82KqZj2piOqkIFU NT4dyeVLATqeeBqGekxu6Z+immD3fVmqbXI+OOWTTkNil4G/VfzFFxLwrn/RWxrdawve j7+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692293092; x=1692897892; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8vHHVkxWW04IoUZrYFRpOEcAsjjg8V3LWudLTC9GREA=; b=lP+C9nJn07zMxmktqVUIilBGHOAuXmB4ZSjC3yfOQsqVveZOo+hxq4lS+U1IinGm2b LnPotdUsUS37xxST+9HYkD4ktw/qpyELkAYCTdX3izH7HTi2T65dx0o+oiCEvtuTVASg vX3/5ybfVHs2mAA2/vmGS/+xCXBU+hgm1K4xdqVyDxas9givSRfmHwgVnBcZ5t1roL6u KpdSnB9daw0TquJy6V1/j/DeCJ8XdRmQSNYHuj5/KW+IYR6Cyb0TIsy4gMdGMdMI8Kio FTHZkrSw5RYTfIBYZxLuP+FVveXVcWMg0mUwrcy1+ssQF7hWjMLgSrhnhEn7hSU40jJL 5G7A== X-Gm-Message-State: AOJu0Yyez8dPyWZy7FnDeiEfJKgoz/qMwzfnkyPCmKPXIMSJL5x5dUXP dpulmcNQ3EF65aDFaHCE47C/rw== X-Received: by 2002:a17:903:22ce:b0:1b8:17e8:547e with SMTP id y14-20020a17090322ce00b001b817e8547emr70150plg.1.1692293092439; Thu, 17 Aug 2023 10:24:52 -0700 (PDT) Received: from [192.168.1.136] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id w6-20020a170902d3c600b001bdf45eb5b6sm12246plb.284.2023.08.17.10.24.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Aug 2023 10:24:51 -0700 (PDT) Message-ID: <12ecac8d-1837-4083-a7e9-efe826d9ae7f@kernel.dk> Date: Thu, 17 Aug 2023 11:24:50 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] blk-mq: release scheduler resource when request complete Content-Language: en-US From: Jens Axboe To: Chengming Zhou , Bart Van Assche , hch@lst.de Cc: oe-lkp@lists.linux.dev, lkp@intel.com, Chuck Lever , linux-block@vger.kernel.org, cel@kernel.org, linux-kernel@vger.kernel.org, kernel test robot References: <202308172100.8ce4b853-oliver.sang@intel.com> <317715dc-f6e4-1847-5b78-b2d8184b446a@linux.dev> <8c262b00-9856-49fa-b425-da863efdff7d@kernel.dk> In-Reply-To: <8c262b00-9856-49fa-b425-da863efdff7d@kernel.dk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 8/17/23 11:20 AM, Jens Axboe wrote: > On 8/17/23 9:29 AM, Chengming Zhou wrote: >> On 2023/8/17 22:50, Bart Van Assche wrote: >>> On 8/17/23 07:41, kernel test robot wrote: >>>> [ 222.622837][ T2216] statistics for priority 1: i 276 m 0 d 276 c 278 >>>> [ 222.629307][ T2216] WARNING: CPU: 0 PID: 2216 at block/mq-deadline.c:680 dd_exit_sched (block/mq-deadline.c:680 (discriminator 3)) >>> >>> The above information shows that dd_inserted_request() has been called >>> 276 times and also that dd_finish_request() has been called 278 times. >> >> Thanks much for your help. >> >> This patch indeed introduced a regression, postflush requests will be completed >> twice, so here dd_finish_request() is more than dd_inserted_request(). >> >> diff --git a/block/blk-mq.c b/block/blk-mq.c >> index a8c63bef8ff1..7cd47ffc04ce 100644 >> --- a/block/blk-mq.c >> +++ b/block/blk-mq.c >> @@ -686,8 +686,10 @@ static void blk_mq_finish_request(struct request *rq) >> { >> struct request_queue *q = rq->q; >> >> - if (rq->rq_flags & RQF_USE_SCHED) >> + if (rq->rq_flags & RQF_USE_SCHED) { >> q->elevator->type->ops.finish_request(rq); >> + rq->rq_flags &= ~RQF_USE_SCHED; >> + } >> } >> >> >> Clear RQF_USE_SCHED flag here should fix this problem, which should be ok >> since finish_request() is the last callback, this flag isn't needed anymore. >> >> Jens, should I send this diff as another patch or resend updated v3? > > I don't think this is the right solution, it makes all kinds of > assumptions on what that flag is and when it's safe to clear it. It's a > very fragile fix, I think we need to do better than that. Well maybe this is actually fine, since we're freeing the request now anyway. I can fold it in the fix, I'll add a comment as well. If this is subtle enough that it caused this issue, we definitely should have a comment on why we're clearing this flag. -- Jens Axboe