From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F51518A6A6 for ; Wed, 29 Jan 2025 04:48:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738126086; cv=none; b=aFyOlK9j4KxUF+CsoulbLh6yyVeWJ00XcvCcWg6E3TzUZt/VaRELyW3Z2rbQsjRb9p3NN2IzSJ5krIifAFTlxSt059rTqhtIOznahV/89fBw1cqvVwkadTx40LzIGMvgWmsv9AErr6M27PdjhP/9dUu+WZH5lbWqA6JVe9auQWo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738126086; c=relaxed/simple; bh=peWcLBmGw9O9vXyRSnEUD3ALTkxdirdqXdZSwpQylRs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dEX1U6AjOsJ0S0PUcoD2G/aCM6D/YRKHkG7+Lv0VcXpYTsPyai/NFqnAp6XKvmSp7sfOrzlN00s0YoyiabltgKUPfzPOI/AoGyWpnSn4eb23C+vvt0053vw9BCe3BENmeNIzmi41D2bV+idNdKEt0QzZbsqtcI0fAZ473RQUEEY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=Lt3k7LRY; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="Lt3k7LRY" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-21644db9f3cso13058235ad.2 for ; Tue, 28 Jan 2025 20:48:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1738126084; x=1738730884; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=9nBAJs/K3XCTXctROPnqYBKk6nvC0nwt2edw8ojQ7lg=; b=Lt3k7LRYozcgFjHizxN+y2ak7j/v6IEqkGVpTv8tthoZnMfYGpuCdQm9k7seLwRa2P IS/pJei54lkDhV3T7E+L+57UjWO54Hv31MPBRNKwGGExtyMSqCKrvG5khjNaf9VKiEXH MjGnYEFAudGKRMPp+nwf6KeJj1nJgxvwewelUGdOMuGF2opy4JiotMf9joMo7sx71scm tPZ0fZ/ujLe5fQLCz02MmQ+nf9XDRFpLfm8jWzyZTCy5s73/t4ZqZzT3B3NOowaN9C8W hxH9m8iQJVLYwlMFPQnpazTR0XW1HcXNKeA3pZOHiVHGAf2/T8MzlUfM2TRqqnw1mRhZ Kgqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738126084; x=1738730884; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9nBAJs/K3XCTXctROPnqYBKk6nvC0nwt2edw8ojQ7lg=; b=RIQRR4/QovK2+xeOqs7TF6kTK8dfzwSfwXtwz1g3lsAQv4QPGq/H9DWeN9Hi4FDP85 5X8xNUOySWG6RjulWzElvI18fV2+fbUcl/Q44PDvH3O/IP/+/ZIQbo/McoI4a81HTi89 lyxYyfKNr9yWet754qEJZgBSMeH5WCiJENtfKfkd+8ANqvR3iIXmRDtAJEsBTk1pSEPq Q0n61Vo3Wb3sJOk7RnqTLZVmVCIN3/c9Q4ph8fHmQ9AAvCy+2O9IbKnATjUIPkfNIR8E VABgtEX6pL8s+AEvTiXtRN5uOrlvLGoIlyAK/bxAdsoMGtOqICEGw44SHJbrzYnNf/w3 tjyQ== X-Forwarded-Encrypted: i=1; AJvYcCXDeJ3Viulf+2MULVLLqHsmhB3x3aLF5svXF9J5z/5HbN0LpcPLzgaZ4c3K1kPLQkw8CPMxsu2Ux1HOaCY=@vger.kernel.org X-Gm-Message-State: AOJu0YyymG8/GEFce0d5p1fPld0y7IuhOElf3AUH7ybX+sKIPbQcbjae p7HrcXuGDm7wE8e/5OpYghcqJNjtE+xMJ3e9AGPGuFMeFS/PVTnVExBcAiSUpMc= X-Gm-Gg: ASbGnctpWWGFQSllUvDdZdac+noT/oSsNx1Adwgh39MNsPZrwfVCYoDPnJOw6z22MiM 7QDdHFvs+2ayOYjykDidsOVcijqj/QTe6gsEBS7XoxBR9ptRFIBGuMZdjyL5S+bgsVvogJVoJ/4 aiQJFsgBpjiRHT0JLTL7T7McxcQZnXwcdwp2jIAl1TZoblf8LKMZvW86fGVSakQSPTH2s6xdPsa 8psLqoSF6jw3iFGXjJ+u0qpmGRHviNQ/5OucMimuMHtr3thQXHDN10X5vXPOHXkbaM0k3HxnPRu 18y4znEfZAoo4xIT+O0AK1TRZQyfvH9/PlMLQezGXJm/pTElHW4= X-Google-Smtp-Source: AGHT+IH2SL9fkJmk2X8K7lTgSkBExNzIhKUEntMRXEEyWswgtjrpKfSvnvK7wAH+UMWjl6oI+Hf7kw== X-Received: by 2002:a17:902:db09:b0:215:6533:f4ee with SMTP id d9443c01a7336-21dd7deeab0mr9770055ad.13.1738126084231; Tue, 28 Jan 2025 20:48:04 -0800 (PST) Received: from [10.254.209.208] ([139.177.225.253]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21da424f39fsm89622785ad.249.2025.01.28.20.47.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jan 2025 20:48:03 -0800 (PST) Message-ID: <784be226-d4a8-43bf-9096-dbb7ca8f0cff@bytedance.com> Date: Wed, 29 Jan 2025 12:47:54 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Re: [PATCH v2 2/3] cgroup/rstat: Cleanup cpu.stat once for all Content-Language: en-US To: Tejun Heo Cc: Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Andrew Morton , Bitao Hu , Yury Norov , Thomas Gleixner , Chen Ridong , "open list:CONTROL GROUP (CGROUP)" , "open list:DOCUMENTATION" , open list References: <20250125052521.19487-1-wuyun.abel@bytedance.com> <20250125052521.19487-3-wuyun.abel@bytedance.com> From: Abel Wu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Tejun, On 1/28/25 4:17 AM, Tejun Heo Wrote: > On Sat, Jan 25, 2025 at 01:25:11PM +0800, Abel Wu wrote: >> There were efforts like b824766504e4 ("cgroup/rstat: add force idle show helper") >> to escape from #ifdef hells, and there could be new stats coming out in >> the future, let's clean it up once for all. >> >> Signed-off-by: Abel Wu >> --- >> kernel/cgroup/rstat.c | 47 ++++++++++++++++++++++++------------------- >> 1 file changed, 26 insertions(+), 21 deletions(-) > > Is this materially better? The existing code has ifdef in one place which > the new code can't avoid. Indeed, # of ifdefs will stay unchanged, but they will be folded into one place inside the bstats[] array quite the same as the definition of the struct cgroup_base_stat, which IMHO won't hurt readability. > The new code is more complex and has more lines. > Does the balance get better with additions of new entries? The line diff is 5, and 4 of them are for readability. If adding one more field into cpu.stat, 1 or 3 lines will be added w/o or w/ ifdef respectively, comparing to 8 or 10 lines without this cleanup. So the balance will be better if cpu.stat extends. And it would also be better cleanup duplicated code for each field. Thanks, Abel