Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163045AbbKTQuI (ORCPT ); Fri, 20 Nov 2015 11:50:08 -0500 Received: from mail-by2on0055.outbound.protection.outlook.com ([207.46.100.55]:11776 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759522AbbKTQuD (ORCPT ); Fri, 20 Nov 2015 11:50:03 -0500 Authentication-Results: spf=pass (sender IP is 63.163.107.173) smtp.mailfrom=sandisk.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=sandisk.com; X-AuditID: ac160a69-f79f76d000007db2-6b-564f4f3883cf Subject: Re: [PATCH 2/9] IB: add a proper completion queue abstraction To: Christoph Hellwig References: <1447422410-20891-1-git-send-email-hch@lst.de> <1447422410-20891-3-git-send-email-hch@lst.de> <564B697A.2020601@sandisk.com> <564C2F01.6020407@dev.mellanox.co.il> <564CC15E.7030602@sandisk.com> <20151120101644.GC24298@lst.de> CC: Sagi Grimberg , "linux-rdma@vger.kernel.org" , "axboe@fb.com" , "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" From: Bart Van Assche Message-ID: <564F4F38.9040505@sandisk.com> Date: Fri, 20 Nov 2015 08:50:00 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151120101644.GC24298@lst.de> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeLIzCtJLcpLzFFi42JZI8azSNfC3z/MoHOzrsX/PcfYLFauPspk cXnXHDaLZ4d6WSy6r+9gs3h9/CmTA5vH9BmbWD0mNr9j99h9s4HN4/MmuQCWKC6blNSczLLU In27BK6Mq9/OshScla44d7mDtYFxslgXIyeHhICJRMveVywQtpjEhXvr2UBsIYETjBLPzvF1 MXI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vZ2nbJLRb+qFr3YTnv+SmXzH/MtWK0W3vsfsK q/4vNZgqtrtmG0e343l3t9CpK9Ikfbe8KnU3d3y82uZSyT9OT+FFBtuX8LPnnq+99nJy0fwI xYmPivuOzjL6aXwuvDhoV8rk+22aLMkHFH5+u7on6kmd30ZRV9GS7Iq9SizFGYmGWsxFxYkA KKwT8A8CAAA= X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11OLC009;1:q/HOocaLQzisVC47TXJJZdBqV2R+n110qImhA4K9wdiZ+BH0AXXOzDTqtS2WRX5uqPZnmYTApAaSIqhQvzHCaCnRE3w9ro7Nn6sJ7qruvN7aFTRC89t8n3pBM9WAZKy7qjlk8nSbdVjVTJ01dCtd1EAvsNaBAp+nXcIVD/a3tr56tXeAf8kvvBbWvy4UomIzHkWYTN6LboTYQwcgmz74iChfsLyX0jvS0y/eUUy2ukhyeoUQtQ0VRY+Zd3/doecUW0UeOhzzl2LSnnQ7uI8fqDOUOmF+wJEkEkg5V8Xqer29TSK1TtaszZ7XTd8G+UW1e6ppf8VTwDGUErXakrP76amJNOXInQZO5MtSXtCunMc9KNpRmsVLRu1y0O92Pu/8HdUPddBwywEDiE7x1fBnGI1JkhE3eAUy7YIE3vAM4Io= X-Forefront-Antispam-Report: CIP:63.163.107.173;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(51234002)(164054003)(479174004)(377454003)(24454002)(189002)(199003)(5007970100001)(11100500001)(65816999)(65806001)(110136002)(64126003)(69596002)(36756003)(2950100001)(80316001)(33656002)(93886004)(54356999)(65956001)(76176999)(586003)(87266999)(5001960100002)(83506001)(77096005)(4001350100001)(86362001)(5008740100001)(87936001)(47776003)(59896002)(50466002)(106466001)(50986999)(230700001)(81156007)(92566002)(189998001)(97736004)(23746002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR02MB300;H:milsmgep12.sandisk.com;FPR:;SPF:Pass;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2PR02MB300;2:tW1L7kHifNdGcj8eO3jVOiDJiNYhIr9aEBvw7u3uIfRDr67Ih7M0YKMf5Et6s+d1seqwzdeqTa+R0tg9dJWzopQuFrKyKN6/whgSMHzG1G7nOE81rik943nd/y8SBY8hyLJswAJ4dS5EvN7EgguV2z9yFbQkktFr7oyILpjeU00=;3:iZzCCyasw6uMhMRrwVM+LGbLZgM2N8onCxqcrfr3mfoogTMbX0EspSYIHCJ4GlbgzMSsFooJlYlQVzq1nfYjerypzaTeI7bbZV+aT4M3rALgYYonwISYAZ/EIIjzN1Yt9Uh/lcoQ6BdFIu51V1bIPirUiv2aR3u/xHe3L0yIdN9FUJWhGMxlOxBaQmGaaJtPhVn+EgFhsP+K1CQHhPFC5p6D+cHFQK/jm6o3bRypqk9Crfzz9Op00lUHVIM4OQnx9klLz3DayaQI2/r+qBiHzg==;25:VDJw+hP5bMBV0/gypMaoa35U9+W5jdMO0D8pbMLpWmgrIJ0RUfVUAftiYo9MZm8fFg0411rjFh49fPfg7YXACSGoSQNe9+f6nYGIWkwgn4BYQgsPtZY85ExJ25aZ0t5TITmerhaIi6DgAffoQdJrLYEfXukmkZajSDx83BBe+cVSM9gbuON+hgQgJxxXaI1EauQW8RseBvkG6W8aabbmfbgLx7qlbbxjtLi/KBpAuDPlltVubAgzbo8J1F73EpAl3C3v5pC6qEgcccCSincntg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(8251501001);SRVR:BY2PR02MB300; X-Microsoft-Exchange-Diagnostics: 1;BY2PR02MB300;20:n5Boc1mJLfuyEVLNaUUohGlOynbML2YJKcWsoOGfEC2SmusOfYSE0HIL08RSAmJZH6FbOclCZB5pUMgqhIbf5nqyUkUAO4FKW6MPv5A2/7Cp/n+ujk2ZGl5pZsk4nTbuthrSTgVhkLsXvwhajp3Rjoe3K0vvV5y2irjQ7PLLwIyrIutVareIJLLLjggUVGtsKpz9wTivH/iS0B9MtObfx22tRig8J02F8Gl4vrtJzyiE7yv8HhTG3RFOVYgI9Me9tIVluo6f6DxkjHjNzIkVsb8nsQNXn0RWLyPq+NzxdlE2t6S4T33rewzBTG55SK1yk2bNqY8h39EVc3OLGMPaFml/vhoPsZ7k3+LA2eGSIrGrO4hSxoH1A0RWGS9GR72HSn8QwwtlwFhoR4eRHRSWGxvP95jkYbwlWcVlwquvJXSsBUmr1smlxv7dddL6u4tDWyEUjOsw36mTTjPmqwQqS3NySbH3YC/C6wrsS4e1XBdeafLjMMvgiSptNEOXCedU;4:u7LgYKAO/teCuGUskl+dfagw1CdpPYl8m+I/bKYep0jWq0zUKef2VmGuFpLmjAHXrFWMMjBF144R/ykUDN/hbgJKbQOutJMhYGoS2Rz18RJi9v4j1YuxSZxAsU3E0Yj0EuwWkTpTN0cvrdwEa2x/lnQA7r0srwaaA1oiOC0bxqj+aA5Ft6WvGRQI77xWaqkRDZOXzkLkIfENlxQ7qIb7INXiUrav8I7LZ5mUKn66B39dre1293Bv3zknb4Iy35niBK79iV/dqwGnHI2FjhJvrin+Ot7b6vXUdTLlUwKDGzSw5W6dj06b79XfY9NhTWmW8LwjPRtBSiSRUgcM4Z5gN4AhR9lZ4JC0c+DKPaxUHxCdAwjaEimh+GxrIgEwFRW1bX6cauoRNNzT7NKV8yAp4Q== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(10201501046)(3002001);SRVR:BY2PR02MB300;BCL:0;PCL:0;RULEID:;SRVR:BY2PR02MB300; X-Forefront-PRVS: 07665BE9D1 X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BY2PR02MB300;23:wPP2pGxqRPTht5WRw6eAu7WsBWdjpbrwab/ONE?= =?Windows-1252?Q?3PdCCnqrVRr5IFiIhassiOfSeYmfuQ2/Mo8OG/u7zrKRdSjJnE6/kWwv?= =?Windows-1252?Q?/d5XF+QcYGPRGvnvIZsz1vX/E/PIIcq/DojhdzkhicaJb5NK0MWpN16A?= =?Windows-1252?Q?yM9aueKqc4TDTWikMZeBuBoY+cLzhOfRH4x+3ogiJbIryQx/MkYnJpG4?= =?Windows-1252?Q?8wo4lmu9Z1m4sG/1hadUokhSwaaLdKyOkCdkhjTQ5d4yXREn3aXJ3VHH?= =?Windows-1252?Q?ky66rWq7aToNlM/lqVQQ+VMWvhIraruTLIa19JiZ82SkQFBzfrQ47o9Y?= =?Windows-1252?Q?nJS87MwKTfpbpThAGQHpVH/2Wpe2dMJHwO6CJrLP/dFE0TM/X3vwWHh0?= =?Windows-1252?Q?QcSZwX4OpHpPXPEi8IYhcGrTWkmYtJh06rJk3uZRQboZ4mbWXrJJ/Iqu?= =?Windows-1252?Q?MZmBr4g5Xk+R81UgnKgAcXyAsTuX52o/vXqO5RSHCMTTGPM9nANTYpDG?= =?Windows-1252?Q?Qhy0WqB3FXf2fJKQGNH/T3hY9wC91DOWlLMK60aCyO/mFMcwFr00J3RW?= =?Windows-1252?Q?ADdqE/egP9MwdTW1XueJ4Fx7kjnsP9IZ00XjlFspP451lV/5FoqWzyxC?= =?Windows-1252?Q?F0f0Nu62DQ80NVaz/OSA3FAKmMvdNYKNOPzkXhF57mTkv57MwYgsw1SE?= =?Windows-1252?Q?Xj0+UIpVsWS1p48BzhHLFosl99xawOy1dYzmDEGaUBatAInnzTqtNxxJ?= =?Windows-1252?Q?pZmIJ+chzdnYJA7zO7FtTrOwXyCyIoNp6GorV3mRfASezKbQd6RtPIFY?= =?Windows-1252?Q?5ycF4JknDa82xlVjPnllN3mR+tUqlK0kOYsd/H18By3MQ8SJ18NQLKRr?= =?Windows-1252?Q?7+1uBJVQRt68YLSO4t/qTsJ4SXMogJ+dZtXxTwFisYlh/8n4prZDo9gq?= =?Windows-1252?Q?VqGIktG8eggNDCyNpgNZ7LR1wFRJLNooHaPEK+T5qaIsxUQ9GLCgsFNV?= =?Windows-1252?Q?ADdZ7Zxmp/tCHPUOOSqUveJl/kpHgE5mugh+vFondKSZwgUTqnvaj1O/?= =?Windows-1252?Q?83nsEF7+LE34b4sDDfgrHZnkyb7Yv8FGrOuRmNlhk5KMp055GQLbYsiX?= =?Windows-1252?Q?LFIOxbJn21rXTAW5YGkWnIt5aZqQUjZCeEgvPNyISHzXAa91REM1aOiH?= =?Windows-1252?Q?qyKV8oimkk+YliiYHlUM9MZPaWxyK0+52l+sW0cwQLKEG/ZgmdEn+xo7?= =?Windows-1252?Q?5zRD1aE0pQ0dYIyCXyosQqF9/XjiHXPos3Rr0=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR02MB300;5:1Z+kWRjKn78+sslblXpDxqRS+BCOiLHsQMvrLvm91N1YRV9W7sQTG5XAjRtgIWF/OZQdlHAz8wvu2S0eb5eBwcYWEc7+L+cOLMp7i4i9ACvmcG9v/FdC/mdW1OglNRV5/zkcqcKlcz1Gq1MG6Hs7SQ==;24:YA59cgrzgOP5My/FXzBEshz/FRUwBilxwZSzsfza3d16SFIZWHLDVjqstmcFcQSU5mlijtO74v4gTfMIRoZlJNA8/IzeVN5k98/gOTAoZbg=;20:8+aBDRorprrComOfFZkBZJ1APpKaK55GyoCoRFp6ws5DsEoACXY0HtuzNNpGzetE6TqLxLctgq8kzuxgum0BAqDPLkkt4CbEZ7G9iDs9m+U6DEyfsiamH7X3BD5tmJedDDqy7uXbq20T22XlBVr3BTcC24ePZko/NHvTcyTkyTWUTX19UFn2cKw/zFWCEluVJ5ttKPatFtw3ZHk3VIt5P90usl4NMTyyuZonUpRVCHLN1TgGYp3m36+azuN2rF1O SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2015 16:50:00.8025 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d;Ip=[63.163.107.173];Helo=[milsmgep12.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR02MB300 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3671 Lines: 112 On 11/20/2015 02:16 AM, Christoph Hellwig wrote: > On Wed, Nov 18, 2015 at 10:20:14AM -0800, Bart Van Assche wrote: >> Are you perhaps referring to the sysfs CPU mask that allows to control >> workqueue affinity ? > > I think he is referring to the defintion of WQ_UNBOUND: > > WQ_UNBOUND > > Work items queued to an unbound wq are served by the special > woker-pools which host workers which are not bound to any > specific CPU. This makes the wq behave as a simple execution > context provider without concurrency management. The unbound > worker-pools try to start execution of work items as soon as > possible. Unbound wq sacrifices locality but is useful for > the following cases. > > * Wide fluctuation in the concurrency level requirement is > expected and using bound wq may end up creating large number > of mostly unused workers across different CPUs as the issuer > hops through different CPUs. > > * Long running CPU intensive workloads which can be better > managed by the system scheduler. Hello Christoph, The comment about locality in the above quote is interesting. How about modifying patch 2/9 as indicated below ? The modification below does not change the behavior of this patch if ib_cq.w.cpu is not modified. And it allows users who care about locality and who want to skip the scheduler overhead by setting ib_cq.w.cpu to the index of the CPU they want the work to be processed on. Thanks, Bart. --- drivers/infiniband/core/cq.c | 11 ++++++----- include/rdma/ib_verbs.h | 5 ++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/core/cq.c b/drivers/infiniband/core/cq.c index bf2a079..4d80d8c 100644 --- a/drivers/infiniband/core/cq.c +++ b/drivers/infiniband/core/cq.c @@ -94,18 +94,18 @@ static void ib_cq_completion_softirq(struct ib_cq *cq, void *private) static void ib_cq_poll_work(struct work_struct *work) { - struct ib_cq *cq = container_of(work, struct ib_cq, work); + struct ib_cq *cq = container_of(work, struct ib_cq, w.work); int completed; completed = __ib_process_cq(cq, IB_POLL_BUDGET_WORKQUEUE); if (completed >= IB_POLL_BUDGET_WORKQUEUE || ib_req_notify_cq(cq, IB_POLL_FLAGS) > 0) - queue_work(ib_comp_wq, &cq->work); + queue_work_on(cq->w.cpu, ib_comp_wq, &cq->w.work); } static void ib_cq_completion_workqueue(struct ib_cq *cq, void *private) { - queue_work(ib_comp_wq, &cq->work); + queue_work_on(cq->w.cpu, ib_comp_wq, &cq->w.work); } /** @@ -159,7 +159,8 @@ struct ib_cq *ib_alloc_cq(struct ib_device *dev, void *private, break; case IB_POLL_WORKQUEUE: cq->comp_handler = ib_cq_completion_workqueue; - INIT_WORK(&cq->work, ib_cq_poll_work); + INIT_WORK(&cq->w.work, ib_cq_poll_work); + cq->w.cpu = WORK_CPU_UNBOUND; ib_req_notify_cq(cq, IB_CQ_NEXT_COMP); break; default: @@ -195,7 +196,7 @@ void ib_free_cq(struct ib_cq *cq) irq_poll_disable(&cq->iop); break; case IB_POLL_WORKQUEUE: - flush_work(&cq->work); + flush_work(&cq->w.work); break; default: WARN_ON_ONCE(1); diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index f59a8d3..b1344f8 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1291,7 +1291,10 @@ struct ib_cq { struct ib_wc *wc; union { struct irq_poll iop; - struct work_struct work; + struct { + struct work_struct work; + int cpu; + } w; }; }; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/