From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (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 40020206F11 for ; Sat, 25 Jan 2025 04:54:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737780894; cv=none; b=uLQ7YQL/Ar8Xn47ELd4otjPtdUauGsEiTRCnV2g/KG4n8htIi2f+Dd7jx4OQBjoTo7PQzSxNBBNn/GSFvDi7f+tYnn6kOHKwhwREXu7iaTAo+Lh/oF4DKzlloUl1w642lCc2ymZl8ZLPyn79typ2HHaRmWm/F1Egg1oTBVM+VDs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737780894; c=relaxed/simple; bh=99zIExNxV8TToDSVXEOlJWH3cgVLTzynrGOeD2kxGAA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=gRJqha1Wv/VWmA+BWrm4GtqCaKyIZdYJdCsuvVZ4tHHJEmEAXeZr+YYcwVG5t7gXMexVv1gCQX8+i50k/G8Xlp6Cuib+gNdMlnONYCB063PfWHiXybhn437EuRbOKkqFuYE/TcSmQYiQxACeogGgnYrXkKWx3zFw6EWcKLJKpP0= 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=eqrcObbZ; arc=none smtp.client-ip=209.85.216.42 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="eqrcObbZ" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2ee534d6800so624447a91.2 for ; Fri, 24 Jan 2025 20:54:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1737780891; x=1738385691; 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=YcNgN6gZIcmY//g8EryXMm8MjUwB/SDjbpwyh5XT/f4=; b=eqrcObbZEOhbJLf1ghTPego94RSfzfsVT5r7qwa/9voiUU7b+PJYAXNsXzpGBGjNu/ odoV5Xu+W7FLoesTzAXcqcv7PZsAf6yAwrxqUlVq32AjCvXeQhFliAAj4ecTmBur9iY3 avY5PSrlt8poQkPB6UdoJTS6aGGHzO5KjdrI3OA+aX8JXjwTVIyugirjEaYI6+PvK+Ye MEJj23uyGDkCpJELCPWdo+sqTtCOZBW2FkeSeC2rEMEqTRlGGAPCOYjA8CaMjAn3REPG 6d99nc/kjmynvP5QsTKKNuPnyFh7PGh2X92ND4m1zqx8Wh814hSZRiUE+TvunqgFURhL 8SOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737780891; x=1738385691; 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=YcNgN6gZIcmY//g8EryXMm8MjUwB/SDjbpwyh5XT/f4=; b=aWnVsydGPR6hzF6ZY8OQuFz/Br2o9vEeaRO3QX8sb00u9Ca+DMlVntPdSik2k2T2rP cFoGiT6bfqdDI3n+wJ03C869tzHQUI3b3jSyD0fAPPSVpOsTf0h0DP+j5L7NnO1OUBSS moUjPbxuDNafxMOhXqK1TGwSlBlR56vhLFGWSJf6i+NCOJ6bxeYvroNCHuYvc770LCIQ +aKVVbzL2hTAAwU9FyTfdPDUcvC5TYvPwKjxANwmohFu0eFwofabYQYdDkd9G68xfZpu 2B04ROjNGTx9yGCOo1XSMSJKgdFvephfinD8zBNC9E1kPrT/v3wfCg72Fgzk7WYsqTvw lNrQ== X-Forwarded-Encrypted: i=1; AJvYcCXTN8iC6JCgp2fvzTLq8Cv8yGwvEMqkUF/Z+3h0dhWqcH0gmp8yy8ArAjl4qkNJxTyRlenoeykOCLgx1jI=@vger.kernel.org X-Gm-Message-State: AOJu0YyAKVnFYZbhNe366E0FVR12CEGyPJgxmKt7lktW0jqBjQKuJxyz fZETiEyc9/okBAy/sM3WGwOjnFC9+/Xk42bTGCB4heErI5E8GZvbChaGEsWnG50= X-Gm-Gg: ASbGncuWq4YX2sZ3dQc+ryq8PA3wIEEBWf651L9SWsqMYQ19Qz0fOUxMzfQ+QMVa6PX wj8lUPEghJugdxhyjFOqy2QwBRVsXXHKeleOw8FirjHt+UweQllfI8RS//dawVU9dsc4VD/r0/7 qM4wNuRU4G+lkeLWM+861ajBoypvIKP4x7SKjsfaX/CDbu8om1/+8mc/IpykCs9tsrqaDvuKukZ d6atB7fxa23EGwgcCk54tVah3+ZKgUQfycmX8ZXu2sWhijn3cVlkGS48H2RpX1N4xyGHCmVh7o1 av/2x7zT9vIzIFWBphNX7scyCQ1y4A== X-Google-Smtp-Source: AGHT+IEGD3EkTIh6y8VfxvJvDoX08GEOp3byEl8/0wwfQdu/2ISPUjOo35Ke9spLN4IHxZe/yYhQkw== X-Received: by 2002:a05:6a20:12cd:b0:1cf:4845:67f with SMTP id adf61e73a8af0-1eb216879bbmr19531476637.9.1737780891383; Fri, 24 Jan 2025 20:54:51 -0800 (PST) Received: from [10.254.144.106] ([139.177.225.251]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a6b47f5sm2825005b3a.70.2025.01.24.20.54.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Jan 2025 20:54:50 -0800 (PST) Message-ID: <5b71f446-8a83-46e1-9e28-fb5f90f78793@bytedance.com> Date: Sat, 25 Jan 2025 12:54:42 +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: Re: [PATCH 1/3] cgroup/rstat: Fix forceidle time in cpu.stat Content-Language: en-US To: Tejun Heo Cc: chenridong , 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 , Thomas Gleixner , Yury Norov , Andrew Morton , Bitao Hu , "open list:CONTROL GROUP (CGROUP)" , "open list:DOCUMENTATION" , open list References: <20250123174713.25570-1-wuyun.abel@bytedance.com> <20250123174713.25570-2-wuyun.abel@bytedance.com> <853d2669-e05b-435e-9ac1-86311ead56e5@huawei.com> <2bba87cf-69aa-4fac-ae1a-c50e2f376e2a@bytedance.com> From: Abel Wu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/25/25 7:49 AM, Tejun Heo Wrote: > On Fri, Jan 24, 2025 at 03:49:16PM +0800, Abel Wu wrote: > ... >>>> --- a/kernel/cgroup/rstat.c >>>> +++ b/kernel/cgroup/rstat.c >>>> @@ -613,36 +613,33 @@ static void cgroup_force_idle_show(struct seq_file *seq, struct cgroup_base_stat >>>> void cgroup_base_stat_cputime_show(struct seq_file *seq) >>>> { >>>> struct cgroup *cgrp = seq_css(seq)->cgroup; >>>> - u64 usage, utime, stime, ntime; >>>> + struct cgroup_base_stat bstat; >>>> if (cgroup_parent(cgrp)) { >>>> cgroup_rstat_flush_hold(cgrp); >>>> - usage = cgrp->bstat.cputime.sum_exec_runtime; >>>> + bstat = cgrp->bstat; >>> >>> Thank you for finding that. >>> In my version 2, I used to assign cgrp->bstat to bstat. >>> This is Tj's comment: >>> https://lore.kernel.org/linux-kernel/ZoQ2ti7nnz9EJSc3@slm.duckdns.org/ > > I wasn't saying that memcpy() should be used instead of assignment. I was > saying that if a non-trivial struct can be pointed to instead of being > copied, it should be pointed to. If all the fields need to be snapshotted, > assigning is fine. Thanks for your clarification, Tejun. I will post v2 to address Michal's comments. Best Regards, Abel