Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1752888pxb; Mon, 12 Apr 2021 06:05:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQ1+pApqPfosdT13VUfXnAvyBoErHKvKRBCWOEXPqwxBorqHz3R92pDNXO7mFA0k2GtiJj X-Received: by 2002:a65:5b85:: with SMTP id i5mr25881349pgr.269.1618232713473; Mon, 12 Apr 2021 06:05:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618232713; cv=none; d=google.com; s=arc-20160816; b=UqoaEx1nXGbo4Gal5Ehl4W3+7C/daXeBMKaFfbTGrLxnX4pMMfXt1m2/SdrJIFpJ3Y s39EL486zr9uASoM6+g0DhgT8TYf56zN+fc8BPpXbZZQBtIb1cLQ3rAk2jurBhDGeQkv a6ZyMz989K8zmXLhz/M72NCPYWNcoAKNoKL/3rlI24+wwPCQRhI+Im8/3D2w4K5qgF+S vp+3dw1c+b7fYt7sQEFBlHq2AtP1KxxRxjrJVIMg6OzFunBqowQYwRP7XSw+JU/dflv+ ojQt4mTJYymL6uxLhqbghOQDOt9cW44djRgWsUp/4h0CNcg+mcpgCDVy2mmRXKfl6Mut HSqg== 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=7U26dWdmUbGOFoEw3WRLyC/HQG/gNKfhazVkTBVrkrg=; b=j15vtcYw7XmGCsTs4UctGUMyoqpZOYVIX18PifcbVEM0vQFewSadCYxF7dDcI9zoz4 GKJMpYn3YpvquqR0Ds7nP1W1mP//wEUt33EzBr+hCxueyP5HkMfjNCJL7w7W+sNOV00b H8JlqnJWOra8dUpeLsDOk7EMmhfYyUlZN4KkTmmrvtBD7Wd8yxjm5McxmUZEOQ/N5G8D ZYpw8bzij1LSvy8zG151aDietS5/jqi43ZtFh0GGBV7n12jn9NGp1C0clC77T+a6249j Zu52rDu+0v0TsYJpdweMe0+aDIYDvjIox5djql9Z8eWUHhc0CZ0pyXqNyNXKOAVwhckN 3Rdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=ck2b8FIh; 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 o24si12445812pgl.48.2021.04.12.06.04.59; Mon, 12 Apr 2021 06:05:13 -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=@ziepe.ca header.s=google header.b=ck2b8FIh; 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 S241603AbhDLNEY (ORCPT + 99 others); Mon, 12 Apr 2021 09:04:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238534AbhDLNEX (ORCPT ); Mon, 12 Apr 2021 09:04:23 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F762C061574 for ; Mon, 12 Apr 2021 06:04:05 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id o17so4705829qkl.13 for ; Mon, 12 Apr 2021 06:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=7U26dWdmUbGOFoEw3WRLyC/HQG/gNKfhazVkTBVrkrg=; b=ck2b8FIh9doK+J+1zK8r2cGgpdvgLvmRcdTIla3+2T2K6FiOyQW8ljFFj5LhjjZgAb qW1Xot4IgLY08JHjSgcGoEgk2q5z0SVjK5DUoixhjW9WeLkuGgKNd5BUL46cUapCcgh1 zlVnEBwuHOoaxppNcZgKw2FvjYUFFgMiKQ7/XkgNBusP+uMB0wIJ03OO4m/C0KCex2zE EwHDRjW3fhJ1vA9WbgBsIfUVQpqwqlriJEvA1Y0hU16x+eFMESuQJr6qPRC2q4BNG/jL ARclik07dgjcoqTQ+JS2IqjCm923+PofupkNQxC9/DVl6DnTOtkPCUaSPSmv5I47c9Go 8ypg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7U26dWdmUbGOFoEw3WRLyC/HQG/gNKfhazVkTBVrkrg=; b=EslYVHqzKtyMkG56mDRJd/au5DDTo5EJPZIKQtZvkePE62E9BDj+r+ml6Ra4kvQkiN DuTIvzFn+XWC7zjXaEHddy4+UAmFka+KBzSIBm0VpYeCif2xkwwKApBg0WSK49Ipq9D0 Pk2NSyRa/leP4a0M9TzFRd13qGU1yXzfS/9+wXS/Zx3+wD1ogHbKXEPO+ItwsNncsBZP Py5aqzBx6qFYI0UPGlA7i7TWGQtvI1Upja3WhswZ/6YV8dPgaFbfquTF6Su3oxEoAC/2 kvcpbnBOLUu+EyXlqbz9SUw2uWQTZXDMafjpTNQFYfeNmIpAd0kvhj26yF0tvqS70JTj 8o1Q== X-Gm-Message-State: AOAM533seOZ6mjyYy8GKBb6P+xGa82OePBggfoQsSfxnWpOVaYDTQ/eF PU/DV6I5T7CrOhq2qNvrcj7sSg== X-Received: by 2002:a37:a1d3:: with SMTP id k202mr19967256qke.97.1618232644399; Mon, 12 Apr 2021 06:04:04 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-162-115-133.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.115.133]) by smtp.gmail.com with ESMTPSA id b198sm7828845qkg.10.2021.04.12.06.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 06:04:03 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lVwEU-004azS-Sp; Mon, 12 Apr 2021 10:04:02 -0300 Date: Mon, 12 Apr 2021 10:04:02 -0300 From: Jason Gunthorpe To: Daniel Wagner Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Steve Wise , Leon Romanovsky , Potnuri Bharat Teja Subject: Re: [PATCH] nvme: Drop WQ_MEM_RECLAIM flag from core workqueues Message-ID: <20210412130402.GF227011@ziepe.ca> References: <20210412122330.5166-1-dwagner@suse.de> <20210412123149.GE227011@ziepe.ca> <20210412124909.olui5hfhceakt4u4@beryllium.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210412124909.olui5hfhceakt4u4@beryllium.lan> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 12, 2021 at 02:49:09PM +0200, Daniel Wagner wrote: > I've grepped through the code and didn't find anything which supports > the guarantee claim. Neither mm nor schedule seems to care about this > flag nor workqueue.c (except the early init bits). Or I must miss > something. It is pretty complicated, but the WQ_MEM_RECLAIM preallocates a thread: static int init_rescuer(struct workqueue_struct *wq) { if (!(wq->flags & WQ_MEM_RECLAIM)) return 0; rescuer = alloc_worker(NUMA_NO_NODE); This comment explains it: * Workqueue rescuer thread function. There's one rescuer for each * workqueue which has WQ_MEM_RECLAIM set. * * Regular work processing on a pool may block trying to create a new * worker which uses GFP_KERNEL allocation which has slight chance of * developing into deadlock if some works currently on the same queue * need to be processed to satisfy the GFP_KERNEL allocation. This is * the problem rescuer solves. * * When such condition is possible, the pool summons rescuers of all * workqueues which have works queued on the pool and let them process * those works so that forward progress can be guaranteed. * * This should happen rarely. Basically the allocation of importance in the workqueue is assigning a worker, so pre-allocating a worker ensures the work can continue to progress without becoming dependent on allocations. This is why work under the WQ_MEM_RECLAIM cannot recurse back into the allocator as it would get a rescurer thread stuck at a point when all other threads are already stuck. To remove WQ_MEM_RECLAIM you have to make assertions about the calling contexts and blocking contexts of the workqueue, not what the work itself is doing. Jason