Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2267871imm; Fri, 7 Sep 2018 13:34:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYQYgTn8Y55CPXcn6M5UcliBCbL97Uz970O0wicDIgCrnQRHyLDNUi6/5gjCBvizfiQiwf/ X-Received: by 2002:a63:6881:: with SMTP id d123-v6mr10109076pgc.298.1536352484497; Fri, 07 Sep 2018 13:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536352484; cv=none; d=google.com; s=arc-20160816; b=LTtmMviW4l8pLDxteoi5e0Kn9bl0f22rrh2dwsOfz3gfXY2fD9zHrWOyYRQzt8iRQA R0+WRCY60UsAPvAYBp6wvGwWpMiYHByH0j3x2sU1O2rEvvPNOPQld9OcUnlKU33nNRf+ Y19685Di64mmtj4IaX7meXJEFVufHnNjGB0pFfU3ED/VFxcLzcv8KNa121cxYSz9qA1J 7YY49YCM3Lwqri02M7JQAOo4ddtolD/UvnuRxoSV1nPM9UUzDj6RSZhpKKEj/wGYeY+5 3boXT9cARAJlaX+j8UYy094FPWnSfzGwaXd3NAeyW0qBIo9GxueX0Ll7hDbQZd8zagZt nceg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FT1JS+mP7s3H0ehWUhrZs7M0IklabbNNqY5+yLxrfIE=; b=Q3nRLBz+4NER5ytEmeNL4W/KUvt+mZAqm5+pxx7JW7J44b/T76suHrHMt3RBGZhJot EnPvqPXDG5Os7CF0c8w8EAa1QB8igo+VKJcK2ubEBbpqqCHvTmnm0AJrWfUuaRnx5HV+ kMrY7NC+2VkttDnMmdvLlhFexbMQKn7QWizxvdvksstla69QTqN5DYfiymQOeHhYeAvn bNqsl+lh8H+VOMVbUX+52OW7f0K3ITtzmcgWY01JR4x1veJThXTKJ02w8lFlp+DBUI/L bu5GqU79HSmwnZ9FYcn3+YCPjYR4gXkD8MWXONHBs8ar1Ho0RPAgnkA9sYPYl0NwTLxn E6oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q1VKss8L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w16-v6si10259186pga.104.2018.09.07.13.34.28; Fri, 07 Sep 2018 13:34:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q1VKss8L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726341AbeIHBQC (ORCPT + 99 others); Fri, 7 Sep 2018 21:16:02 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:33955 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725986AbeIHBQB (ORCPT ); Fri, 7 Sep 2018 21:16:01 -0400 Received: by mail-yb1-f195.google.com with SMTP id t10-v6so5924192ybb.1; Fri, 07 Sep 2018 13:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=FT1JS+mP7s3H0ehWUhrZs7M0IklabbNNqY5+yLxrfIE=; b=Q1VKss8Lue+m3hZoEmC1iP9DFK/xjg8lz1z8J7Ujsr7HryEXQRC1lTg8wqGJFvxEO+ bd6Jb9sfUf7vD4tNZT9y3zGccUxxhlimUzWYrXJuwB9/mafY4IGuHQxR0mAMY/8DVqKk XPbtVip+rWcYNrCiTrrmfWfHMAklxPNakcHRBTmKYMRkB1bUWmQqU3ur/ge1Obdv8mrK o2ZhlPouil/4ldzGShrmQDbafb2xbiaTEhebWY9C25oDyu8JjAGeXmn5OW4edWw48Ze2 3543IoWePb2R+ECB4s6AqNpjWBWVtm1Da2qpk8YD3a2iOVqn81bdIt7Ii0P0psva5JXm NLrg== 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:user-agent; bh=FT1JS+mP7s3H0ehWUhrZs7M0IklabbNNqY5+yLxrfIE=; b=kr1RdP94MBMQdAsp8gCvDMd4ASU/i1UsA5TeBLj794hofNsWWsIjyGDj4/qX7iPFIC f9yOgrn80fowUsYPjv+a5QfrIAyu7Hv9sVpr5hiX0dCgCptKt3RH6qD63wuljH1EMT/W Ha+wp08OHLFJBemkKy6lijCzr6crE491T5tgUksf1Jt1JlHqIwep/yAeQqhSXygEm/y3 t+R1bKd9V5M8PKtlecUZgdJI3PbXe9iSeIqzHIiyXWHhldzRmqI0XdV7FWa+r/fAcWh1 EbfSfArOzJH9ToxjrLdkTnThd4NfWe2O53iPHSa/8iZyWlIVI2wDWx2qT5j1t8rEVwCX UO3A== X-Gm-Message-State: APzg51AuiDUTIxWUb8Lj5VXE9Xnfkvvo7/YE8iqqE+U8vkvex1v8m3Gz NIMWDWxvZwaTF85bGG6ncD8= X-Received: by 2002:a25:cfd2:: with SMTP id f201-v6mr5127679ybg.317.1536352404475; Fri, 07 Sep 2018 13:33:24 -0700 (PDT) Received: from dennisz-mbp.dhcp.thefacebook.com ([2620:10d:c091:200::9697]) by smtp.gmail.com with ESMTPSA id o193-v6sm3430213ywd.84.2018.09.07.13.33.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 13:33:23 -0700 (PDT) Date: Fri, 7 Sep 2018 16:33:21 -0400 From: Dennis Zhou To: Tejun Heo Cc: Jens Axboe , Johannes Weiner , Josef Bacik , kernel-team@fb.com, linux-block@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 03/12] blkcg: convert blkg_lookup_create to find closest blkg Message-ID: <20180907203320.GB97913@dennisz-mbp.dhcp.thefacebook.com> References: <20180906211045.29055-1-dennisszhou@gmail.com> <20180906211045.29055-4-dennisszhou@gmail.com> <20180907172730.GB1100574@devbig004.ftw2.facebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180907172730.GB1100574@devbig004.ftw2.facebook.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tejun, On Fri, Sep 07, 2018 at 10:27:30AM -0700, Tejun Heo wrote: > Hello, > > On Thu, Sep 06, 2018 at 05:10:36PM -0400, Dennis Zhou wrote: > > @@ -2021,9 +2021,7 @@ int bio_associate_blkg(struct bio *bio, struct blkcg_gq *blkg) > > { > > if (unlikely(bio->bi_blkg)) > > return -EBUSY; > > + bio->bi_blkg = blkg_try_get_closest(blkg); > > return 0; > > It prolly would be a good idea to point out that the associated blkg > might not be the same one passed in. Maybe this gets cleared up later > in the series? > Heh. I added comments everywhere else but the place it's used. Updated. In hindsight though, it does make it a little problematic here as you may have a different blkg than css. FWIW, it makes the next few patches easier to read as they don't need to do nontrivial error handling that will eventually be ripped out. And this is to really handle the edge cases of OOM and dying cgroups. If you think it's worth fixing I can go back through the set and adjust it all. > > @@ -298,14 +297,23 @@ struct blkcg_gq *__blkg_lookup_create(struct blkcg *blkcg, > > while (true) { > > struct blkcg *pos = blkcg; > > struct blkcg *parent = blkcg_parent(blkcg); > > - > > - while (parent && !__blkg_lookup(parent, q, false)) { > > + struct blkcg_gq *ret_blkg = NULL; > > + > > + while (parent) { > > + blkg = __blkg_lookup(parent, q, false); > > + if (blkg) { > > + /* remember closest blkg */ > > + ret_blkg = blkg; > > + break; > > + } > > pos = parent; > > parent = blkcg_parent(parent); > > } > > > > blkg = blkg_create(pos, q, NULL); > > - if (pos == blkcg || IS_ERR(blkg)) > > + if (IS_ERR(blkg)) > > + return ret_blkg ?: q->root_blkg; > > Why not ret_blkg here? > ret_blkg is only set if a parent exists. I can move that up to the definition to remove the extra branch. Thanks, Dennis