Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1323827pxb; Fri, 27 Aug 2021 06:29:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuv/9z1RrEGjNCBljPUNshWxH4+lp9dyMsFPPidTAsvrAqmQGCiu3J288UsVfkcKcXwjLK X-Received: by 2002:a05:6e02:20cd:: with SMTP id 13mr6598068ilq.156.1630070995565; Fri, 27 Aug 2021 06:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630070995; cv=none; d=google.com; s=arc-20160816; b=pwkR7/6eYkRYsAGTT7o6e/OpLi3AcQUy9fcUtOkpUfxodxvLQFBvYztbkvWvJyBm0k SS53yQyKbGvuTqWg+5B9pGjwl4KLmjx02RGrYEmEM+mLANCTWdEswEu/JN3OhFDGnxQ+ Jl6MscWtkSyp/aodVAZx9vHXTACkjq3NTgd5mRgMLWak9spgIdTWM/Fge5Bsxh8pl3d/ 8v+6P+TrLyaBtRr633BNCaJ9dYVg87NI+bfl1D4nA4I4vyAKNUzEztTcIK9tImGSq1Pc TVYR7Xyu6wk+Q1btSZmm7W8KDHuMC/Wt/IV1aCbJiSj75zTujuKqu6zACq+mP1yYUao2 y0xw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aserqfxgK4j648DubNeStR0HBDeNL2sC/ZgY9Ze9vt4=; b=wbbzlQj7JJtg4wyhv63BVM2vI9jbgnzmwb2zUVjNDlBPxSXDUJx7do0sz9DaZ7kv4S E34Rya9wD4PMv2zV84K3CXMrirTpWD+DgpE9Dq3hiz9pdRvzeA40Qjc7rBLOguZF59bv Tgfhvt0GNkySqixfx11wCfCXtq7yQli51XCnzn9wlXg49o3oYgE1mOM6HHvYdzfIZTNM HDVFujqh08w1MzUBGfyarvaHOAUWR3Q3Iip4S8ukGV50M89WPcKPy9Cm8aIA9QZ+4qoU 3wQqxibbK80Fs+9s5nps68oFXGPWGiEWCxzSajRr6AvtHUPpGd6SrR2ojE6dqZo2j883 58OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DpKiJ10l; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e10si5933682ilc.155.2021.08.27.06.29.43; Fri, 27 Aug 2021 06:29:55 -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=@redhat.com header.s=mimecast20190719 header.b=DpKiJ10l; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232335AbhH0N3c (ORCPT + 99 others); Fri, 27 Aug 2021 09:29:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59453 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231932AbhH0N3N (ORCPT ); Fri, 27 Aug 2021 09:29:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630070903; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aserqfxgK4j648DubNeStR0HBDeNL2sC/ZgY9Ze9vt4=; b=DpKiJ10l5q/RPXA23/hiXqkBOx3EI1BmGlbvj6S1qEP3cnPUwXEqwdLLCplXK8W2bFzVxg /dwvh/0c/7rY0oql2x+XK+p/w0WyrYLcZoCEPHCbCU7YenGnI8jOy9zV23I2fYlMBHiIIW 7vNXzzlyR1XC+YFk1ala3phEna7+zfg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-517-2qT1BMhXPcaSOYLyD0plAg-1; Fri, 27 Aug 2021 09:28:22 -0400 X-MC-Unique: 2qT1BMhXPcaSOYLyD0plAg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10224190A7A1; Fri, 27 Aug 2021 13:28:21 +0000 (UTC) Received: from T590 (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84DC15DA60; Fri, 27 Aug 2021 13:28:11 +0000 (UTC) Date: Fri, 27 Aug 2021 21:28:07 +0800 From: Ming Lei To: Niklas Cassel Cc: Jens Axboe , Bart Van Assche , Damien Le Moal , Paolo Valente , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC PATCH 1/2] blk-mq: don't call callbacks for requests that bypassed the scheduler Message-ID: References: <20210827124100.98112-1-Niklas.Cassel@wdc.com> <20210827124100.98112-2-Niklas.Cassel@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210827124100.98112-2-Niklas.Cassel@wdc.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 27, 2021 at 12:41:31PM +0000, Niklas Cassel wrote: > From: Niklas Cassel > > Currently, __blk_mq_alloc_request() calls ops.prepare_request and sets > RQF_ELVPRIV. > > Therefore, (if the request is not a flush) the RQF_ELVPRIV flag will be > set for the request in blk_mq_submit_bio(), regardless if the request > was submitted to a scheduler, or bypassed the scheduler. > > Later, blk_mq_free_request() checks if the RQF_ELVPRIV flag is set, > if it is, the ops.finish_request callback will be called. > > The problem with this is that the finish_request scheduler callback > will be called for requests that bypassed the scheduler. > > Fix this by calling the scheduler ops.prepare_request callback, and > set the RQF_ELVPRIV flag only immediately before calling the insert > callback. One request could be inserted more than one times, such as requeue, however __blk_mq_alloc_request() is just run once, so is it fine to call ->prepare_request more than one time for same request? Or I am wondering why not call ->prepare_request when the following check is true? if (e && e->type->ops.prepare_request && !op_is_flush(data->cmd_flags) && !blk_op_is_passthrough(data->cmd_flags)) e->type->ops.prepare_request() Thanks, Ming