Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1535776pxb; Wed, 4 Nov 2020 11:33:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvOkXEwdF2NnOsnEvVQ4iE6JxNmJFrnb7rJgB4iSAjTEzKgVt+iDRB++3+NEIzXdUoE7cf X-Received: by 2002:a05:6402:10c7:: with SMTP id p7mr28580909edu.34.1604518384055; Wed, 04 Nov 2020 11:33:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604518384; cv=none; d=google.com; s=arc-20160816; b=gXk3PmYWDTTeBkUK0aZYVqGkuFW7u95LzLbRzRpJrjVr+aw7OE67Trlcioktp8q0Hq 7Bk/j7MTSfVKpugIjd9j21J+Qln6y2hhSOeUQl1URS7QBRvM5tL+ICgNsvDrrhfncSuh i9PIks/0bKMxL3QA/CXG+YlEYpLp1QUiB0E8jJUl0dCVuCPjaoubAOvtMaFuZPxDQ5UY X0xnD9+5bA0wRx2J2YuNlBACO1xcuysXbWc1eGU8DNrG8xwbLuAL97mrl9EqCEIamPKC KQ4TK4vZI8Jb3q1yK0C2ldxLxuZjI4j0qPtFvZ+/g128yA2sBJdQbvmT3sWtJSaMQhe0 cFmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=7v8XNWb378ZY/CjlNvIn/30UioBbrTjZQwuMGRkG3IQ=; b=HLBqoBxmOu7rYsYVW2MI1e40rNh+HdRzmLwOsaNNLr+ErUuQrhnbia83kwfsL9DAuH 7Jqy9fwJjeDeBkaxNV1zdHvZyxkxTjBVRumDBFfxqg/rVpDg0WFZ57crXh2X24TnyRMp Qlij8aFvsunm4NrjCMgARbAlw+QfX+Zx0/Y8nQIIdcS52AhrloNsXO62nwvj/4svO31e /HWvUrTS7f6SdTs9nFLwCIkRG00a2eDv5FRfiYnsGuJkL3wgMvweFxPBYdeyXzE3zJZ4 bnDwX/jfPWPYK8xoBrzhxjleDkfLzG3BYMrFJfvy7xyQQojgyxk9cnWfTBU9EVJ1L5uO BEHw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz8si2103647ejb.312.2020.11.04.11.32.41; Wed, 04 Nov 2020 11:33:04 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731436AbgKDTPe (ORCPT + 99 others); Wed, 4 Nov 2020 14:15:34 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:40364 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726564AbgKDTPe (ORCPT ); Wed, 4 Nov 2020 14:15:34 -0500 Received: by mail-wm1-f66.google.com with SMTP id k18so3364280wmj.5; Wed, 04 Nov 2020 11:15:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=7v8XNWb378ZY/CjlNvIn/30UioBbrTjZQwuMGRkG3IQ=; b=EWmns0/p6rhEnpxVmtUx4KY5rW8XtODDRB55Fd5q7SgcHF3xz7otJDvpCHoAqDOLKF swHbrN4ZQUlrbo98SFAZx9RQDB7VdgM0F+dpJQLD4fHUVXTpKDirSDRjN2ewKTqQac2P jHmyAuyBK3ylKJM4LgUxNlP173qIRfmp3UmyhGPlD3vU9PNs4Z+FK7eh19mlLaqtfJPf XNz/nngtLHa8OVa45Tw/4LljEGorm32t2kwt7OnI6jnsE0CxGtD3t3pXyd4LEO6f7ofC FLBMTkXYyqVpUHPL6oCLiVEyUODdBzjr0E0VFLtQ3HsR0Zk74bBapgN7O2KPayBLPpGS LOdA== X-Gm-Message-State: AOAM530ZfGKKitBoUYHSQ5cmYJbuyZRl5cLhRi4UTHHG3+leqmQGBGdw uTMwU3rBKHuRHlLlCyNY0Hk= X-Received: by 2002:a1c:3103:: with SMTP id x3mr6148797wmx.107.1604517331370; Wed, 04 Nov 2020 11:15:31 -0800 (PST) Received: from ?IPv6:2601:647:4802:9070:f032:e586:d54c:b9cb? ([2601:647:4802:9070:f032:e586:d54c:b9cb]) by smtp.gmail.com with ESMTPSA id n4sm3498536wmi.32.2020.11.04.11.15.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Nov 2020 11:15:30 -0800 (PST) Subject: Re: [PATCH 3/3] blk-mq: Use llist_head for blk_cpu_done To: Christoph Hellwig , Sebastian Andrzej Siewior Cc: Jens Axboe , linux-block@vger.kernel.org, Thomas Gleixner , David Runge , linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Daniel Wagner , Mike Galbraith References: <20201029131212.dsulzvsb6pahahbs@linutronix.de> <20201029140536.GA6376@infradead.org> <20201029145623.3zry7o6nh6ks5tjj@linutronix.de> <20201029145743.GA19379@infradead.org> <20201029210103.ocufuvj6i4idf5hj@linutronix.de> <20201031104108.wjjdiklqrgyqmj54@linutronix.de> <3bbfb5e1-c5d7-8f3b-4b96-6dc02be0550d@kernel.dk> <20201102095533.fxc2xpauzsoju7cm@linutronix.de> <20201102181238.GA17806@infradead.org> From: Sagi Grimberg Message-ID: <75970f9d-7e59-5fba-280a-d0d935fc4d2f@grimberg.me> Date: Wed, 4 Nov 2020 11:15:27 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201102181238.GA17806@infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>> There really aren't any rules for this, and it's perfectly legit to >>> complete from process context. Maybe you're a kthread driven driver and >>> that's how you handle completions. The block completion path has always >>> been hard IRQ safe, but possible to call from anywhere. >> >> I'm not trying to put restrictions and forbidding completions from a >> kthread. I'm trying to avoid the pointless softirq dance for no added >> value. We could: > >> to not break that assumption you just mentioned and provide >> |static inline void blk_mq_complete_request_local(struct request *rq) >> |{ >> | rq->q->mq_ops->complete(rq); >> |} >> >> so that completion issued from from process context (like those from >> usb-storage) don't end up waking `ksoftird' (running at SCHED_OTHER) >> completing the requests but rather performing it right away. The softirq >> dance makes no sense here. > > Agreed. But I don't think your above blk_mq_complete_request_local > is all that useful either as ->complete is defined by the caller, > so we could just do a direct call. Basically we should just > return false from blk_mq_complete_request_remote after updating > the state when called from process context. Agreed. > But given that IIRC > we are not supposed to check what state we are called from > we'll need a helper just for updating the state instead and > ensure the driver uses the right helper. Now of course we might > have process context callers that still want to bounce to the > submitting CPU, but in that case we should go directly to a > workqueue or similar. This would mean that it may be suboptimal for nvme-tcp to complete requests in softirq context from the network context (determined by NIC steering). Because in this case, this would trigger workqueue schedule on a per-request basis rather than once per .data_ready call like we do today. Is that correct? It has been observed that completing commands in softirq context (network determined cpu) because basically the completion does IPI + local complete, not IPI + softirq or IPI + workqueue. > Either way doing this properly will probabl involve an audit of all > drivers, but I think that is worth it. Agree.