Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4623993imm; Wed, 30 May 2018 08:55:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJGwlV/tN5C0e/+9yLVJ4cOIVfGkha9gwd92kik/bPFw2WC/l7oHRnfwyut0dcwnCW44LoP X-Received: by 2002:a17:902:b418:: with SMTP id x24-v6mr3374520plr.2.1527695722310; Wed, 30 May 2018 08:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527695722; cv=none; d=google.com; s=arc-20160816; b=JmPcfq6qCH1q97DHgqwfZB8I2qCMro+2tbMC+ltb2FyO8zgZr09JUn4GzBbFGoElAC sdLxVWIRSBhlboxX8kcVKAZVCsdVMdReeRQ3d/OAcuad/eWuF5ID4RmTNIVmAABoReFc qBCbKI9iv36Oezc3js1e6ZtXrUVTnR4mASTQcRC3vb5XB4UrfHGytBXJggOYEOatgviR Hwyxzzl3N76VQLmTMuk4Y/NVIuBx1P1MRPpZbtJp2q0DrKgxJAvoulX1pPbJoFEfvkVl FUyWGRRRMQDVrg4rSJQWIaqofHevqCAu/Z5cccZhb8RqmJhWECXeJROHSW0O14G2ZrON RDJA== 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:arc-authentication-results; bh=Av883XiiJdpktG271pxGRS4cCkhlGqfJcIH+6k7Jjw8=; b=diRH1Kwg1kCdGpiVjSODvB0jhoWdA6E6OytcRIv5RDr22XCna69KsvIKhi1z3Es0WB fpISCqVq05d4rUyMgpNyGM1xY2JzGjHNXVmAL0PKAMsa3x9jZR0CNxlKnrlXes1Vl3Hh P6EqomF+dqp3lyMz8JYzOBqlPj9iEJKey9LnSVsEqx4DX/7Vzs3PEClTVeWOcq2ls2Yf TluzP2LrwMLKhUlezjx3+dTtCWeG858UN0IQB0sBs1V9OaBFi5Uf5U6cspHZTEV2w/3T Tl7E7mTd/EkCoK9UjhGIiUcGT5k7NGdV+5UX0lhuNLCZ0H3Yz9eQxWA2Z32s6TmRjXA8 VYFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=bFhxRs1d; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c27-v6si4336420pgn.320.2018.05.30.08.55.08; Wed, 30 May 2018 08:55:22 -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=fail header.i=@gmail.com header.s=20161025 header.b=bFhxRs1d; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753788AbeE3Pyi (ORCPT + 99 others); Wed, 30 May 2018 11:54:38 -0400 Received: from mail-yb0-f196.google.com ([209.85.213.196]:33922 "EHLO mail-yb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751817AbeE3Pyg (ORCPT ); Wed, 30 May 2018 11:54:36 -0400 Received: by mail-yb0-f196.google.com with SMTP id i1-v6so6531943ybe.1; Wed, 30 May 2018 08:54:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Av883XiiJdpktG271pxGRS4cCkhlGqfJcIH+6k7Jjw8=; b=bFhxRs1dGyQ4IigCAMBCj7QBOhbdCEzKkHXRYWzogMCIHYfox+vkAKJlJ4lTOi8ZHt jTPfyNit/XO1YqejaeLEAyPR4bGzDb9bUE/GRZG315UUDKsyqHWafEm3OIPe2PBcJWnj QF5gHdpQVcnlsvm5tDAodn7Hq/FsSalZ0zeOABJSj/ilfs/7mt5/kt875dfQxJQbAHtp HETTDbZnYHNqMbNVLblVzElvvYy5gEjrbgxV/bvxtdVxSvj1x88+uyaZwCfhz9oJWiyk vq4ClZcE74lGbT8ewoPq2lURuC8VmlxMXyjkLyIsIr5oMsIkLJ/qAQgPE++qOXLAyfIR 0Sdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=Av883XiiJdpktG271pxGRS4cCkhlGqfJcIH+6k7Jjw8=; b=Mu8TWDK7Rnhz1DxV0ltA6uJ9vP/7lrXWnyhNieYyrchTgb69mf4ZSrkNjeK24lMWiQ o3dANIwwj3xTTiw+NGBQ2tE8NTPWL9qiizICoUqcdZj92jWEw2WBX3x6qh2j6DJoABUC KhMbDQH9AAUTl73Af7pkyFNxCWBhPbvk8qYRzXtx75K8JZlrPEsKrYt4EYHqlKe8YMa6 BBcmQfkF7989CGU7M9EurhjZGnnhsUhyI53/qIe82TyMXF6gBJ4eCNbKpzFxf3aHaZw7 ePoGDJLyqwjVJ+V1OWQmZg1Ho4czULnWGI0Vqc8aH7aAFylE5mKwIU5s362ffDjwf28w oipw== X-Gm-Message-State: ALKqPwcBGmJ0mxDYsjsJ/4mps2QUMeA+LwsYmiSj9lEy2OscoOyjR4U0 FKSMlYOLJCIujg5rsM2jEus= X-Received: by 2002:a25:6509:: with SMTP id z9-v6mr1813028ybb.28.1527695675377; Wed, 30 May 2018 08:54:35 -0700 (PDT) Received: from localhost ([2620:10d:c091:180::1:6002]) by smtp.gmail.com with ESMTPSA id r12-v6sm14446679ywl.59.2018.05.30.08.54.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 May 2018 08:54:34 -0700 (PDT) Date: Wed, 30 May 2018 08:54:32 -0700 From: Tejun Heo To: Josef Bacik Cc: axboe@kernel.dk, kernel-team@fb.com, linux-block@vger.kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Josef Bacik Subject: Re: [PATCH 03/13] blk-cgroup: allow controllers to output their own stats Message-ID: <20180530155432.GK1351649@devbig577.frc2.facebook.com> References: <20180529211724.4531-1-josef@toxicpanda.com> <20180529211724.4531-4-josef@toxicpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180529211724.4531-4-josef@toxicpanda.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 29, 2018 at 05:17:14PM -0400, Josef Bacik wrote: ... > + mutex_lock(&blkcg_pol_mutex); > + for (i = 0; i < BLKCG_MAX_POLS; i++) { > + struct blkcg_policy *pol = blkcg_policy[i]; > + > + if (!blkg->pd[i] || !pol->pd_stat_fn) > + continue; > + > + count = pol->pd_stat_fn(blkg->pd[i], buf, size); Wouldn't it be easier to simply pass in the seq_file? > + if (count >= size) > + continue; > + buf += count; > + total += count; > + size -= count + 1; > + } > + mutex_unlock(&blkcg_pol_mutex); > + if (total) { > + count = snprintf(buf, size, "\n"); > + if (count >= size) > + continue; scnprintf() might make this less painful. > + total += count; > + seq_commit(sf, total); > + } Thanks. -- tejun