Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2160599imu; Thu, 24 Jan 2019 08:10:09 -0800 (PST) X-Google-Smtp-Source: ALg8bN6aPXiujrRSG7p52v5w/UHWQKwMuNuo9Z6sF45HBeCFGmMFDGyVORcijS8snE9MvH9xf32a X-Received: by 2002:a65:40c5:: with SMTP id u5mr6288273pgp.46.1548346209264; Thu, 24 Jan 2019 08:10:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548346209; cv=none; d=google.com; s=arc-20160816; b=zRWgpbdxjZWqLnx1qq3cGeKIo/gppVHV+wh3TQcwxaEGzwtHMspDZl76/2jh45IEQ8 GJf3TptyzP1jO3lULsps4Wpz0BUbyKDfH2l8q2s0ZXwtOe0utamvP6o45xTPn8H6PZ1z jEkri0L1aySTecAbFAUtzGkaV/heUcqIMuqVoYNfMZnMB4WetA8l7HjJbzTRNwLi9pIY RUhaoynpZYiof68VYcDn15RlGRjMdQRz8qvNt5F39qIa6KJ52NY3qq6YQCvlvy3a6sFa wTV3bnMCufDTyCH/B17sroBvhxILX9BR6TOTTxpeOao1i/JqXS4fsXlkCPQdrCFBLZyt WwWQ== 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=cGQ/TMSWGm6i6QwmVNwOtbEz6FvQrTiXlzQK44rHJwA=; b=QW0cyWJnKJ6nhhG5hVcdoo2+QTy0ZEHFTsBBZPge1phzt25SYC1oglbGL4LBzV9izt Fl9sCF4XQKIDnm+SU8W9prpp1mjM8wkeFeE6eWWn/WxViWPypSqhDyBxPC7S8f0EhQBe e5VU0fGK/IwI6/R1WrReJxrfBxlhsfYdM1r5hE7LErD5AuW8a8ogSHVw8YvipRqBjdhi wdMmLqZWUMuze0B/6zrRz+Acb8hb+i4qw/3l3ijDOhxuw92hpzkzdi7rWkpctSZ826mG qIhIt0Q9XCGt4t9Ox1mOQFTlKoLdcQFDI42phC7qz638SNazgbu92H0VrB32FuAn8/GL ONPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=Vp9BWMMN; 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=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u4si22149096pls.34.2019.01.24.08.09.52; Thu, 24 Jan 2019 08:10:09 -0800 (PST) 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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=Vp9BWMMN; 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=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728662AbfAXQJi (ORCPT + 99 others); Thu, 24 Jan 2019 11:09:38 -0500 Received: from mail-yb1-f194.google.com ([209.85.219.194]:39586 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728056AbfAXQJi (ORCPT ); Thu, 24 Jan 2019 11:09:38 -0500 Received: by mail-yb1-f194.google.com with SMTP id s17so2574587ybp.6 for ; Thu, 24 Jan 2019 08:09:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=cGQ/TMSWGm6i6QwmVNwOtbEz6FvQrTiXlzQK44rHJwA=; b=Vp9BWMMNtSD8xSzhnjEWyK0/Ha4ZrmqLfO7rXLLtXOYMU6a5cu7VVhnyEe8K2lx2I1 /rfcdNbrUq1qGtrnNo3W8bcy/7whXZ+wPvxFaBn4lNJ35C48xU8cfqmJs7PBzVTBE1PU VqdUExIZne/b7ck8gktsq9gjbmK6VSzEocsS8MF+941BDqwcdCht1y+Sov8y6iEyBc7L wVLvILvIkOQoHBQEQAD8r2B1RsPLkuHQCgTxmTknmdIuZGpUGeC24ObTfdYapJuoOBru EWvTKEnOvE/3v7nz9v9Lbfzu2ViuHKN1YOFWKMSUfAkfgBsV4fh89kgL/iYCAA2MDmSN Tv6Q== 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=cGQ/TMSWGm6i6QwmVNwOtbEz6FvQrTiXlzQK44rHJwA=; b=WtdATx21FZwvlKi+zhKSbyVmjZryGcaJgpJOqBhnk0N0asug64xHqIvy7bjfMf2tmM igS8KmI6luF2unX2m78q7d0XqduW0GgD9Iylj00mChxcsJAc5IB3jnjRtyNNCN8RNLIV jaP+b+zQg672m1A/TqmN9FgdSZWIyE8lu/sxdVuDrVaHHleyLjrD5HdtPnOIUJHtVgwo U4hPGcLi5/N+quWkwyaQsAOQu2oXyKd0A4RycORt9SaRxqksaSbWJlPynDrl/nrYd2TK oadI7YWmU2yjM0AAmLm+G1L0hVi8L98fxnWFYJQOKht4AQ/jtoopgq91KNDoJSLX4zP4 48OQ== X-Gm-Message-State: AJcUukeejhroZmg+ygDvGNTcs1XIBNC83OywPf1MXTkAfQHm6JzuYzHc 1t0mxRK3oOsNF5eEUTVYp8mqD98XSIU= X-Received: by 2002:a5b:a89:: with SMTP id h9mr6466531ybq.409.1548346177229; Thu, 24 Jan 2019 08:09:37 -0800 (PST) Received: from localhost ([2620:10d:c091:200::5:9b5d]) by smtp.gmail.com with ESMTPSA id s35sm12295052ywa.19.2019.01.24.08.09.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Jan 2019 08:09:36 -0800 (PST) Date: Thu, 24 Jan 2019 11:09:35 -0500 From: Johannes Weiner To: Chris Down Cc: Andrew Morton , Tejun Heo , Roman Gushchin , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, kernel-team@fb.com Subject: Re: [PATCH] mm: Move maxable seq_file logic into a single place Message-ID: <20190124160935.GB12436@cmpxchg.org> References: <20190124061718.GA15486@chrisdown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190124061718.GA15486@chrisdown.name> User-Agent: Mutt/1.11.2 (2019-01-07) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 24, 2019 at 01:17:18AM -0500, Chris Down wrote: > memcg has a significant number of files exposed to kernfs where their > value is either exposed directly or is "max" in the case of > PAGE_COUNTER_MAX. > > There's a fair amount of duplicated code here, since each file involves > turning a seq_file to a css, getting the memcg from the css, safely > reading the counter value, and then doing the right thing depending on > whether the value is PAGE_COUNTER_MAX or not. > > This patch adds the macro DEFINE_MEMCG_MAX_OR_VAL, which defines and > implements a generic way to do this work, avoiding fragmenting logic. > > Signed-off-by: Chris Down > Cc: Andrew Morton > Cc: Johannes Weiner > Cc: Tejun Heo > Cc: Roman Gushchin > Cc: linux-kernel@vger.kernel.org > Cc: cgroups@vger.kernel.org > Cc: linux-mm@kvack.org > Cc: kernel-team@fb.com > --- > mm/memcontrol.c | 78 ++++++++++++------------------------------------- > 1 file changed, 18 insertions(+), 60 deletions(-) I think this increases complexity more than it saves LOC, unfortunately. The current situation is a bit repetitive, but much more obviously correct. And we're not planning on adding many more of those memcg interface files, so I this doesn't seem to be an improvement re: maintainability and future extensibility of the code.