Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752290AbdCDTXI (ORCPT ); Sat, 4 Mar 2017 14:23:08 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35048 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752019AbdCDTXG (ORCPT ); Sat, 4 Mar 2017 14:23:06 -0500 Date: Sat, 4 Mar 2017 11:23:03 -0800 From: Tejun Heo To: Tahsin Erdogan Cc: Jens Axboe , linux-block@vger.kernel.org, David Rientjes , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] blkcg: allocate struct blkcg_gq outside request queue spinlock Message-ID: <20170304192303.GA29316@wtj.duckdns.org> References: <20170303192325.GB22962@wtj.duckdns.org> <20170304014005.23773-1-tahsin@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170304014005.23773-1-tahsin@google.com> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1485 Lines: 49 Hello, Tahsin. Generally looks good. Please see below. > @@ -184,24 +185,48 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg, > + if (unlikely(!wb_congested)) { > ret = -ENOMEM; > goto err_put_css; > + } else if (unlikely(!blkg)) { > + ret = -ENOMEM; > + goto err_put_congested; > } I'm not sure this error handling logic is correct. We can have any combo of alloc failure here, right? > @@ -694,9 +695,20 @@ static inline bool blkcg_bio_issue_check(struct request_queue *q, > blkg = blkg_lookup(blkcg, q); > if (unlikely(!blkg)) { > spin_lock_irq(q->queue_lock); > - blkg = blkg_lookup_create(blkcg, q); > - if (IS_ERR(blkg)) > - blkg = NULL; > + > + /* > + * This could be the first entry point of blkcg implementation > + * and we shouldn't allow anything to go through for a bypassing > + * queue. > + */ > + if (likely(!blk_queue_bypass(q))) { > + blkg = blkg_lookup_create(blkcg, q, > + GFP_NOWAIT | __GFP_NOWARN, > + NULL); > + if (IS_ERR(blkg)) > + blkg = NULL; > + } Heh, this seems a bit too fragile. I get that this covers both call paths into lookup_create which needs the checking, but it seems a bit too nasty to do it this way. Would it be ugly if we factor out both policy enabled and bypass tests into a helper and have inner __blkg_lookup_create() which skips it? We can call the same helper from blkg_create() when @pol. Sorry that this is involving so much bikeshedding. Thanks! -- tejun