From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39CEFC2B9F4 for ; Mon, 28 Jun 2021 14:17:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D732961C75 for ; Mon, 28 Jun 2021 14:17:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D732961C75 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 24A528D0058; Mon, 28 Jun 2021 10:17:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FC1B8D0016; Mon, 28 Jun 2021 10:17:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 074618D0058; Mon, 28 Jun 2021 10:17:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id C022A8D0016 for ; Mon, 28 Jun 2021 10:17:22 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A63108249980 for ; Mon, 28 Jun 2021 14:17:22 +0000 (UTC) X-FDA: 78303335124.17.79BB54A Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) by imf20.hostedemail.com (Postfix) with ESMTP id 602F8369 for ; Mon, 28 Jun 2021 14:17:22 +0000 (UTC) Received: by mail-qt1-f180.google.com with SMTP id r20so13669786qtp.3 for ; 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=UL5Jm7Y+cPu+ZgselNO2r2xKh365Y/+bn8xsikrmf4WJI0MdktwdidCsTuQg+rutSA UTzx7FyWxZogGcXg0lz+QANcdn5aaRfncU1c51Pi9ljvvWlfcz2o2c+MIhRQwzE3u3cy KFlhNYwwnQSOuZuHhk6HTQe7rfSn0JrzjBAs2veK3DDTKugkm5eRQtrDeW/x+er3DFPR X60FgtupdQ5AAZ2qNxCaS/Bjxsv+ok4l7PLIkR9w44bLEcw4frlTVfEEi1TfBmzjyxwm 4MUZ6LHXzmiv2ULIjVM/dShHwWdVCpQ6CzP5yByyFRXWwyrFMAOgdYvgx5xFjxoLq5SV dvlA== X-Gm-Message-State: AOAM530o8ieRjBZvZglvf5Rv0Moq5GNtqingmjpTn7VPRGlgC2+Zynf3 i2BiVxZxpVmKYTtXuy2PogI= X-Google-Smtp-Source: ABdhPJyNwBsHos6I7IJOPlG9XtcqNTMTXUx/rehkBcgB+xJcMBgfooSu+WsH+JQVJryhhPEEKH8pGQ== 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 In-Reply-To: Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=ou9qWijq; spf=pass (imf20.hostedemail.com: domain of schatzbergdan@gmail.com designates 209.85.160.180 as permitted sender) smtp.mailfrom=schatzbergdan@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 602F8369 X-Stat-Signature: 16gajmwfxspbqj3b8mxjumod4fofd61g X-HE-Tag: 1624889842-459408 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Michal, On Fri, Jun 25, 2021 at 05:01:03PM +0200, Michal Koutn=FD wrote: > Hi. >=20 > 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 t= o > > the backing file and also associates the memcg so if the backing file= is > > on tmpfs, memory is charged appropriately. > >=20 > > This patch also exports cgroup_get_e_css and int_active_memcg so it > > can be used by the loop module. >=20 > 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? >=20 > > @@ -2111,13 +2112,18 @@ static blk_status_t loop_queue_rq(struct blk_= mq_hw_ctx *hctx, > > } > > =20 > > /* always use the first bio's css */ > > + cmd->blkcg_css =3D NULL; > > + cmd->memcg_css =3D NULL; > > #ifdef CONFIG_BLK_CGROUP > > - if (cmd->use_aio && rq->bio && rq->bio->bi_blkg) { > > - cmd->css =3D &bio_blkcg(rq->bio)->css; > > - css_get(cmd->css); > > - } else > > + if (rq->bio && rq->bio->bi_blkg) { > > + cmd->blkcg_css =3D &bio_blkcg(rq->bio)->css; > > +#ifdef CONFIG_MEMCG > > + cmd->memcg_css =3D > > + cgroup_get_e_css(cmd->blkcg_css->cgroup, > > + &memory_cgrp_subsys); > > +#endif > > + } > > #endif > > - cmd->css =3D NULL; > > loop_queue_work(lo, cmd); >=20 > I see you dropped the cmd->blkcg_css reference (while rq is handled). I= s > 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.