From patchwork Thu Jan 2 14:01:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hillf Danton X-Patchwork-Id: 11315805 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 136371395 for ; Thu, 2 Jan 2020 14:02:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DB6CC217F4 for ; Thu, 2 Jan 2020 14:02:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB6CC217F4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0367D8E0005; Thu, 2 Jan 2020 09:02:18 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F02678E0003; Thu, 2 Jan 2020 09:02:17 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA5338E0005; Thu, 2 Jan 2020 09:02:17 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0141.hostedemail.com [216.40.44.141]) by kanga.kvack.org (Postfix) with ESMTP id C02258E0003 for ; Thu, 2 Jan 2020 09:02:17 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 7D1AF2C8A for ; Thu, 2 Jan 2020 14:02:17 +0000 (UTC) X-FDA: 76332858714.26.plate14_6b16a31dd0e44 X-Spam-Summary: 2,0,0,4c6cd9d0d199ab0c,d41d8cd98f00b204,hdanton@sina.com,:linux-kernel@vger.kernel.org:axboe@kernel.dk:ming.l@ssi.samsung.com:hch@lst.de:keith.busch@intel.com::hdanton@sina.com,RULES_HIT:41:355:379:800:960:973:988:989:1260:1311:1314:1345:1437:1515:1534:1541:1711:1730:1747:1777:1792:2194:2198:2199:2200:2393:2559:2562:2731:3138:3139:3140:3141:3142:3165:3352:3865:3866:3867:3870:3872:5007:6119:6120:6261:7903:10004:11026:11334:11537:11658:11914:12043:12296:12297:12438:13069:13311:13357:13894:14096:14181:14384:14721:21080:21212:21627:21990:30054,0,RBL:202.108.3.21:@sina.com:.lbl8.mailshell.net-62.18.2.100 64.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: plate14_6b16a31dd0e44 X-Filterd-Recvd-Size: 2045 Received: from r3-21.sinamail.sina.com.cn (r3-21.sinamail.sina.com.cn [202.108.3.21]) by imf39.hostedemail.com (Postfix) with SMTP for ; Thu, 2 Jan 2020 14:02:15 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([114.244.160.153]) by sina.com with ESMTP id 5E0DF7D9000161CB; Thu, 2 Jan 2020 22:02:04 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 125472628753 From: Hillf Danton To: linux-kernel Cc: Jens Axboe , Ming Lin , Christoph Hellwig , Keith Busch , linux-mm , Hillf Danton Subject: [RFC PATCH] blk-mq: prefer local cpu on allocating request Date: Thu, 2 Jan 2020 22:01:52 +0800 Message-Id: <20200102140152.17088-1-hdanton@sina.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.003970, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use local cpu in order to avoid the risk of overloading the first mapped one if completing requests has to be on the cpu where requests are dispatched. Signed-off-by: Hillf Danton --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -426,7 +426,6 @@ struct request *blk_mq_alloc_request_hct { struct blk_mq_alloc_data alloc_data = { .flags = flags, .cmd_flags = op }; struct request *rq; - unsigned int cpu; int ret; /* @@ -454,8 +453,14 @@ struct request *blk_mq_alloc_request_hct blk_queue_exit(q); return ERR_PTR(-EXDEV); } - cpu = cpumask_first_and(alloc_data.hctx->cpumask, cpu_online_mask); - alloc_data.ctx = __blk_mq_get_ctx(q, cpu); + + /* prefer local cpu if it's mapped to hw queue */ + if (!cpumask_test_cpu(raw_smp_processor_id(), alloc_data.hctx->cpumask)) { + unsigned int cpu; + cpu = cpumask_first_and(alloc_data.hctx->cpumask, cpu_online_mask); + if (cpu < nr_cpu_ids) + alloc_data.ctx = __blk_mq_get_ctx(q, cpu); + } rq = blk_mq_get_request(q, NULL, &alloc_data); blk_queue_exit(q);