Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp176646lqo; Wed, 15 May 2024 10:52:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWms4nSZaV8l/0hluh0hxzvIBiBYZswTjcOm1InQBfb8N3xnGLCYBF8udDR/KLzy5TcIM8LqmxXN9RSDJkz27bU7r+BD4jM5UiJPF9BSg== X-Google-Smtp-Source: AGHT+IFUhTuc9lQDApbef6c3sPugmPDmRlTbUf22avgHbhk8YbTtfy025zzcw8hP6wzKeJTlt38P X-Received: by 2002:a05:6a00:13a6:b0:6ea:b073:c10c with SMTP id d2e1a72fcca58-6f4e029cbefmr26070859b3a.6.1715795550542; Wed, 15 May 2024 10:52:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715795550; cv=pass; d=google.com; s=arc-20160816; b=aowgtw1iqAdRBgeaS3jc9ePMYmHQwWukAgV+SINDYvb+ZfNmHGgTL7cTtJFwta01n/ zXLz78+nWK0F681T7JHqnv9eoW7cdO9+OwFMGd9N70NUbBVQuzF3KRKabecnqVo33NdZ VzoRuiuBy4ckwQ4s/kvL7hnrCP7kjex1Jh7ZJLGtcghiOoZQltgfQyEOuVMPGds5VR1c I1hXaz+vJDO6usmBtnI7mUkEPU2GJIRNIABV7GkSf3R2xVFUdFcllSvkQS78OkvhRy6y jIVJ7StvfGwC1tFCUCY/GLrwPFaKBVWe/bqYSQWyvE89BFYeC58/n8Dei/nijpL1mz0t 7k2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=tHDwRLQMXKViJqBxui2sWgU6FvNiXKY1AhcnSoBsYMk=; fh=xOFniQNuD0rsEIJpAgDsgdsNX3cs1HaoMXoaWZDSpSQ=; b=sudiTbPUOS7cVOjNxxw/bujn61Rejrm0fX6SCr3djNMnyIQLQ9IG+nHgLK/ST+Rq9l ILb3aCkoTa3qnPy2pZn/3rEs4qz1wxjf3zX09RV8+N4msFX8v9Df/k84/OCy0Q5DrkYh OM/R6S3/3ULeRS/Rx1yvezPLSPdyWLgMAvqK+S7vpAyX8MQideHpl6ChnhKn4V1tT2VB n9DVDXrG8IwB+vSJeGwF8DbWaDrpy39/5acajyyYkVknNTgCeQmOAAOCVg1fGSdUuwd4 2xePQ16AGJCnEzA1n2heFIAzEFuxhr4VbGFI9Od3LJJFCKAGPZuw8Rd9EYN9lPfhzq4R 850g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KRMdemJ9; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-180233-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180233-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-654eb3d98fesi1730872a12.120.2024.05.15.10.52.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 10:52:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180233-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KRMdemJ9; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-180233-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180233-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C04822866F1 for ; Wed, 15 May 2024 17:51:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C2B8158D76; Wed, 15 May 2024 17:51:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KRMdemJ9" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1268E158A24 for ; Wed, 15 May 2024 17:51:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715795511; cv=none; b=d3qc2NLbBaR/a32EnYodjb4DHl45iEQlu+b4yyMZXELyePrVo2R5bUOkebAP6bObTaFroYcjQPUF5wNGjUvC1x9Og0GG2wTkd6My7SRe4e/rzpc1OqxExGrRwJE8ieZ4LBjPPwP0K311fzYl016TW5/QMYZKsqp6qv2JWbq2AoI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715795511; c=relaxed/simple; bh=rpJyHwPj75U5yJhb0iHm0cH8HZqi7oZYM4aRh7yf4eA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ptHq8AN/jd6bHXr2urFEegOyKdfxxtzMvZSdeQtNwE0GP2wkb1UOS1aiwxhaCj89hq2SuNdi8OiKsgIoYdQN5DEo9mlNqwIB7QQOTzY8ZwIAz4CdszbI0EhHsYuc1eDrNIOPAkhae+DvGOqbecT7EbscKtmWODDi4GqAgXHyJ8s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=KRMdemJ9; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715795508; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tHDwRLQMXKViJqBxui2sWgU6FvNiXKY1AhcnSoBsYMk=; b=KRMdemJ9bXarS1GStEu+CZEnczLP/hGmm77QMjGSND7a/dNmhyVZjjRv5QCBzZiXJahftd QF79r+5h71XI+0cGiQ3+Hk5KLf95Xk2on0XVCFP4hN4IG9u2grfLVkfmPm6TY32DWLAsGE dHZPTRx74Qgm2t+p2ilsLCLCivmxQdg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-215-54LJ7ZUwOgmIWFTKlNc18Q-1; Wed, 15 May 2024 13:51:42 -0400 X-MC-Unique: 54LJ7ZUwOgmIWFTKlNc18Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B508F29AA393; Wed, 15 May 2024 17:51:41 +0000 (UTC) Received: from [10.22.9.0] (unknown [10.22.9.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id 716572026D68; Wed, 15 May 2024 17:51:41 +0000 (UTC) Message-ID: <31cef5e2-cf6e-42df-a6d2-10ecd04e60d7@redhat.com> Date: Wed, 15 May 2024 13:51:41 -0400 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: cgroup io.stat propagation regression To: Dan Schatzberg Cc: Tejun Heo , linux-block@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org References: <3ed32279-904a-411d-91a4-a62f4ca2dde2@redhat.com> <11b8c1e4-45a7-4895-a1f3-6626744cee1e@redhat.com> Content-Language: en-US From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 On 5/15/24 12:54, Dan Schatzberg wrote: > On Wed, May 15, 2024 at 10:26:31AM -0400, Waiman Long wrote: >> On 5/14/24 23:59, Waiman Long wrote: >>> On 5/14/24 15:25, Dan Schatzberg wrote: >>>> Hi Waiman, >>>> >>>> I've noticed that on recent kernels io.stat metrics don't propagate >>>> all the way up the hierarchy. Specifically, io.stat metrics of some >>>> leaf cgroup will be propagated to the parent, but not its grandparent. >>>> >>>> For a simple repro, run the following: >>>> >>>> systemd-run --slice test-test dd if=/dev/urandom of=/tmp/test >>>> bs=4096 count=1 >>>> >>>> Then: >>>> >>>> cat /sys/fs/cgroup/test.slice/test-test.slice/io.stat >>>> >>>> Shows the parent cgroup stats and I see wbytes=4096 but the >>>> grandparent cgroup: >>>> >>>> cat /sys/fs/cgroup/test.slice/io.stat >>>> >>>> shows no writes. >>>> >>>> I believe this was caused by the change in "blk-cgroup: Optimize >>>> blkcg_rstat_flush()". When blkcg_rstat_flush is called on the parent >>>> cgroup, it exits early because the lockless list is empty since the >>>> parent cgroup never issued writes itself (e.g. in >>>> blk_cgroup_bio_start). However, in doing so it never propagated stats >>>> to its parent. >>>> >>>> Can you confirm if my understanding of the logic here is correct and >>>> advise on a fix? >>> Yes, I believe your analysis is correct. Thanks for spotting this iostat >>> propagation problem. >>> >>> I am working on a fix to address this problem and will post a patch once >>> I have finished my testing. >> Actually, I can only reproduce the issue with a 3-level >> (child-parent-grandparent) cgroup hierarchy below the root cgroup. The dd >> command is run test.slice/test-test.slice. So both test.slice/io.stat and >> test.slice/test-test.slice/io.stat are properly updated. > That's correct, this repros with a 3-level cgroup hierarchy (or > more). systemd-run should create an ephemeral .scope cgroup under > test-test.slice and then delete it when the dd command finishes. So > test.slice/test-test.slice was the parent (2nd level) and test.slice > is the grandparent. OK, I didn't get the .scope sub-cgroup when I ran the above systemd-run command. Perhaps it's due to a difference in configuration. Anyway, I was able to reproduce the problem and devise the fix accordingly. Thanks, Longman