Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3556445pxv; Mon, 28 Jun 2021 07:19:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8xpYYABknjC6e41vsMQqXrkQ4hE/i6S7e2R5UIap+Er2Q6G+2m/XNt9iMaBlT/B33/c77 X-Received: by 2002:a92:c7c5:: with SMTP id g5mr18951997ilk.153.1624889986303; Mon, 28 Jun 2021 07:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624889986; cv=none; d=google.com; s=arc-20160816; b=d7xhibMhPdQj6CsHjwEhTnx/bFvEiKsG7MkjOczkphtjpNmgsryfClqIJBzBXtOU85 FhvK2N/PnEv9XE2b6NkBKE60Tzrfcr+ZVMJyzBUlfG2fANys0nci2nBDJ1nI6aFODwps pxYgCTbVG/x0Bo3BCFeQrqbaG7h+ZS9iKNeQuai6+uKb6zj+fVX5z9mSv9rNlHx9rx9+ Be7nW8bitPb46qJSO5w5w4h+4ds6rf/EcME4JBKr1BzFfLdvA3Kr+5FUA8XUGE/8hee2 4IWdoow7mcpRdmOvFatEQ7T8FuslTx6ZvNVAHKWhadR/dUw/CADvc9uBdlEyK02MnMjZ ht0w== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vAguyIyi4MmUNdlCWw+ELLDz19W9ZtG5NXhufd99HQU=; b=UYL5PlPJhsqzhw8m/gBIUcuLPmCeaq3Jcheq0zqHimEb+RHMWBqtgew9mdNeb/NXWp /eGDEMZn+XFQdDpqFU5gISNOzUnaxhlq7btFUE+P9ZXNfyb6WdYvOI/kYE2UCQamta/M fuYmcuoMsecJWXMNzlx3+64dxSZ4akQjbapg21gc4iiUnaAz3+TSROtQIp+vQa1sa1wV stilwVvUbrsHk8El05SrLwk9EjkG0iCH0Jo5TR5EerYGSZVBpcUm2rbStUtxx6ZDbyeM +vBwSuRicvnULG1AVKAfT7SuVnGRX+t76BF4A5mt/xvku9Twk+KLdY66bDkcvP+GgTqB TNaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ou9qWijq; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si15486066ilb.8.2021.06.28.07.19.32; Mon, 28 Jun 2021 07:19:46 -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=@gmail.com header.s=20161025 header.b=ou9qWijq; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232519AbhF1OTt (ORCPT + 99 others); Mon, 28 Jun 2021 10:19:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230154AbhF1OTt (ORCPT ); Mon, 28 Jun 2021 10:19:49 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AB64C061574; Mon, 28 Jun 2021 07:17:22 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id r7so13619061qta.12; Mon, 28 Jun 2021 07:17:22 -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:content-transfer-encoding:in-reply-to; bh=vAguyIyi4MmUNdlCWw+ELLDz19W9ZtG5NXhufd99HQU=; b=ou9qWijqI8+uRu9wJxljIWLESJnGibgJlZ1RbImShcDy9ys4gRS9l4WX13763vB6o1 JYtM7iFmX6tYN1xnyCqvBwoh3DV1nEe9s8ExkS7XaCO+6bnVGIJk2/0zmzghc7V7BIPy 52vif2t67eC4ft8m9AqigMctzHoCFjQmhqbj3vQSF4zC2GHEu5KT6up2sHp5z6YDQN0y eHhJWR0+P8S9SC9MqmnfSvuCOto5l6Y0RRxPdsx8B4xvemH3LvFiAzHk3i4G0pmhIAja jG3ZKv0SZKOXE5TxMKShSOdKq9czRuZ9nniTCuv85w8uglqMShEaWC/85HkJdvP/TFmx xw/Q== 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:content-transfer-encoding :in-reply-to; bh=vAguyIyi4MmUNdlCWw+ELLDz19W9ZtG5NXhufd99HQU=; b=jKG4n0BfSnqviM5np3y1O4ivRElqJEUjywUG+pXw95P0n3e+4fauxwN5bbyCflkI57 rvx6ic4ejqZgBGeQksqaG7mREm67ufaznJbHetVAQvDOFEMnbM5kctWzUnkzQZmRs45y gjNsTHVJ/z+t+ioa03t0uaMOXRmXSeHX3dCzeYrJRcNedOJ1bXVd3h99KcEP6Q82nJzM X82lLhbEh1EDvI5+MpJs3P7pHEuwq2TlVHPRqZ+JzvWIUdGiL2MjjhEnNep5RaJVfZQ1 +Rj8N7y1B2rrp7B0Q+0AJFgIvJ+i+Cx6MCu3pU0CTuoRvwEBX9V5pYqdUwmci/+Niknu sQNw== X-Gm-Message-State: AOAM533//+PB0xqEKLHpMnC8OtCT6uFihNJp0Uorrg6mGQhyX4JLus12 2nMwvkociE7P42+eeRoInXEyWW8Dprk= X-Received: by 2002:ac8:5ac3:: with SMTP id d3mr19216337qtd.73.1624889841494; Mon, 28 Jun 2021 07:17:21 -0700 (PDT) Received: from dschatzberg-fedora-PC0Y6AEN ([2620:10d:c091:480::1:85ab]) by smtp.gmail.com with ESMTPSA id y7sm10651104qkp.103.2021.06.28.07.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 07:17:20 -0700 (PDT) Date: Mon, 28 Jun 2021 10:17:18 -0400 From: Dan Schatzberg To: Michal =?iso-8859-1?Q?Koutn=FD?= Cc: Andrew Morton , "open list:BLOCK LAYER" , open list , "open list:CONTROL GROUP (CGROUP)" , "open list:MEMORY MANAGEMENT" , Johannes Weiner , Jens Axboe Subject: Re: [PATCH 3/3] loop: Charge i/o to mem and blk cg Message-ID: References: <20210610173944.1203706-1-schatzberg.dan@gmail.com> <20210610173944.1203706-4-schatzberg.dan@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michal, On Fri, Jun 25, 2021 at 05:01:03PM +0200, Michal Koutn? wrote: > Hi. > > On Thu, Jun 10, 2021 at 10:39:44AM -0700, Dan Schatzberg wrote: > > The current code only associates with the existing blkcg when aio is > > used to access the backing file. This patch covers all types of i/o to > > the backing file and also associates the memcg so if the backing file is > > on tmpfs, memory is charged appropriately. > > > > This patch also exports cgroup_get_e_css and int_active_memcg so it > > can be used by the loop module. > > Wouldn't it be clearer to export (not explicitly inlined anymore) > set_active_memcg() instead of the int_active_memcg that's rather an > implementation detail? Agreed that exporting int_active_memcg is an implementation detail, but would this prevent set_active_memcg from being inlined? Is that desireable? > > > @@ -2111,13 +2112,18 @@ static blk_status_t loop_queue_rq(struct blk_mq_hw_ctx *hctx, > > } > > > > /* always use the first bio's css */ > > + cmd->blkcg_css = NULL; > > + cmd->memcg_css = NULL; > > #ifdef CONFIG_BLK_CGROUP > > - if (cmd->use_aio && rq->bio && rq->bio->bi_blkg) { > > - cmd->css = &bio_blkcg(rq->bio)->css; > > - css_get(cmd->css); > > - } else > > + if (rq->bio && rq->bio->bi_blkg) { > > + cmd->blkcg_css = &bio_blkcg(rq->bio)->css; > > +#ifdef CONFIG_MEMCG > > + cmd->memcg_css = > > + cgroup_get_e_css(cmd->blkcg_css->cgroup, > > + &memory_cgrp_subsys); > > +#endif > > + } > > #endif > > - cmd->css = NULL; > > loop_queue_work(lo, cmd); > > I see you dropped the cmd->blkcg_css reference (while rq is handled). Is > it intentional? Yes it is intentional. All requests (not just aio) go through the loop worker which grabs the blkcg reference in loop_queue_work() on construction. So I believe grabbing a reference per request is unnecessary.