Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2682680rdb; Wed, 15 Nov 2023 07:46:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEKdgEu0kJPHUFP1zfb+wTF02NzdprzQFU8bFQssASWJBDh2Q8LTaOXcZCfeP9lxM4t+qoP X-Received: by 2002:a17:902:f814:b0:1cc:cff:43b6 with SMTP id ix20-20020a170902f81400b001cc0cff43b6mr4897689plb.54.1700063191571; Wed, 15 Nov 2023 07:46:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700063191; cv=none; d=google.com; s=arc-20160816; b=CYfImus4kcmuU2oauh8K83VwWhSXfVwDMkK3uzlnArZ8xATbDtq0Io4eh/w0VMJydr e0PYnL5HU+XvMDdbfNYvWsPMT7Y0J+Ml0jR4PviW0OQy6c9NyMP4tY0UEGHK8POqkwgk nWPh20N7gyjEQCIo3R6ON8EDh1Viuh4XtzuMvv85BEX4Yc595Y+/DRg6hC8KchaIXZVK RNaPV1OgCR95gITPpKA6iDKxTywUDAJv1sqn9OZhe24/Dsha6QEziTQZhIVgboqdctAk rRWTfHWPvoqcgGlcLiezdSVHjfSbgCFpyLah3B7ms+SXgomjLwBA9qZHAYrex9dhJGeo Iptg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=TgKBpBpUp5Uchf6c8nfJ48+uMer2uL0hQhrnnxEiiIM=; fh=MF2P+SSli1gLl2gyXaHrGgvKNitHI/ur3qKirpfhTUc=; b=bF+XTqx6WRhSPnm331uz7HRCHvapj2GnRSOC/TFzl6L6CV/+AGLOzfLa1RtQougWFw Axln405TScMa7pAG5ZdslcvEzDGk6gwQN9IQB1Ehp2VBTGpdZTbPFcHGPk6uy8m0gvld Wf0Xuoe0XKnhIfeL+Q2P/MYLjcmRkR9EUX67c3hX38xvVr/xpNGlxGEiiwVOkLvu4NvL zRbqFxfXusT7aepJVri+iBo8EO1KT66bvU3rolUDVe5bvSv69+epw92qlixrm3xZrVsa RlJjRsuNa/kpTL5CxKT64nICH4IXnDdusMibbY+LJkJjuV+zQOPGRieFk/qAVPo/YbCW /isg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 139-20020a630091000000b005c1b5a5213esi3888766pga.768.2023.11.15.07.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 07:46:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0E1F48038F3C; Wed, 15 Nov 2023 07:46:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231439AbjKOPpz convert rfc822-to-8bit (ORCPT + 99 others); Wed, 15 Nov 2023 10:45:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjKOPpy (ORCPT ); Wed, 15 Nov 2023 10:45:54 -0500 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C5E4109; Wed, 15 Nov 2023 07:45:51 -0800 (PST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1cc2575dfc7so52419265ad.1; Wed, 15 Nov 2023 07:45:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700063150; x=1700667950; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9if1LcIDYWn+6yGIa/i9Vugk0aDMVHzwYt5FrtAY5k4=; b=sK8CrnbF3IlmeFi3rFMe4c2oYKhJ5yZMPdKJHM5AM+q54JUi0X/97KzQ+v+SmEULzc BUAk4pemlY5Nr2COMjKcrudUV34Pw0pU08oGCnlamSSs0PQfQZQKAvrcxrMR3Ia8W35y 9VAb+loG8Q6m9V6JzsEQuzV7ZOx5OZ+roEwxk0q5EzUPW6xxTXI/HoLvTgM7sMxdCwQQ ffDNPP71HvH/u1BvtnPP2e6WqCVmKsOMFQO+YYtj8/haStrjdJbprXadvVhOExkm+ecU mrsKqejn7aoFKceFLSMxsNpMi7YpMr9AKuaMYGZOymYCYYGZ/HB7ugT4KWoSS+TwcXcr pmFA== X-Gm-Message-State: AOJu0YwUikkT4vjGv8rNPVFkN7cl2xnW2WRI1kdr7gHFo0byNK9uMUmD ay3CDcpAPW7pevlq5l21/tsSj2br1c+HiExUAwE= X-Received: by 2002:a17:90b:4f45:b0:280:2935:af23 with SMTP id pj5-20020a17090b4f4500b002802935af23mr11945134pjb.5.1700063150440; Wed, 15 Nov 2023 07:45:50 -0800 (PST) MIME-Version: 1.0 References: <449fb8d2.27fb.18bcc190021.Coremail.00107082@163.com> <76d75357.6ab6.18bce6b7d5b.Coremail.00107082@163.com> <20231115103241.GD3818@noisy.programming.kicks-ass.net> In-Reply-To: <20231115103241.GD3818@noisy.programming.kicks-ass.net> From: Namhyung Kim Date: Wed, 15 Nov 2023 07:45:38 -0800 Message-ID: Subject: Re: [Regression or Fix]perf: profiling stats sigificantly changed for aio_write/read(ext4) between 6.7.0-rc1 and 6.6.0 To: Peter Zijlstra Cc: David Wang <00107082@163.com>, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 07:46:01 -0800 (PST) Hello, On Wed, Nov 15, 2023 at 2:32 AM Peter Zijlstra wrote: > > > Namhyung, could you please take a look, you know how to operate this > cgroup stuff. Sure. > > On Tue, Nov 14, 2023 at 11:20:32PM +0800, David Wang wrote: > > > > > > At 2023-11-14 12:31:12, "David Wang" <00107082@163.com> wrote: > > >Hi, > > > > > >I was making kernel profiling to identify kernel changes between revisions under the load of fio benchmark, > > > > >But I did not notice a significant change in the overhead of perf tracing based on the fio report, > > >that is why I am not sure whether this is a regression or an improvement.... > > >Just report the change. Do you mean f06cc667f79 ("perf: Optimize perf_cgroup_switch")? Did you have cgroup events when you ran the benchmark? Otherwise it should not make any differences. > > > > > > > I run the same test on another disk which is almost idle all the time, and still, significant perf sample stats changes detected: > > > > 6.7.0-rc1 > > > > aio_write(49.340% 131501/266521) > > ext4_file_write_iter(94.567% 124356/131501) > > iomap_dio_rw(78.494% 97612/124356) > > __iomap_dio_rw(99.550% 97173/97612) > > iomap_dio_bio_iter(47.773% 46422/97173) <<---- > > blk_finish_plug(29.931% 29085/97173) <<---- > > iomap_iter(14.082% 13684/97173) > > kmalloc_trace(1.814% 1763/97173) > > kiocb_invalidate_pages(0.631% 613/97173) > > invalidate_inode_pages2_range(0.448% 435/97173) > > srso_return_thunk(0.320% 311/97173) > > blk_start_plug(0.167% 162/97173) > > > > > > 6.7.0-rc1 with f06cc667f79 reverted > > > > aio_write(49.071% 155873/317649) > > ext4_file_write_iter(95.211% 148409/155873) > > iomap_dio_rw(81.816% 121422/148409) > > __iomap_dio_rw(99.684% 121038/121422) > > iomap_dio_bio_iter(40.280% 48754/121038) <<--- > > blk_finish_plug(36.760% 44494/121038) <<--- > > iomap_iter(14.657% 17740/121038) > > kmalloc_trace(1.775% 2149/121038) > > kiocb_invalidate_pages(0.599% 725/121038) > > invalidate_inode_pages2_range(0.330% 399/121038) > > srso_return_thunk(0.263% 318/121038) > > blk_start_plug(0.169% 204/121038) I cannot say whether it's good or not just by looking at these numbers. Maybe fs/block folks know.. > > > > > > I remove the 4 occurrences for checking nr_cgroups: > > > > diff --git a/kernel/events/core.c b/kernel/events/core.c > > index 683dc086ef10..7583418e94d9 100644 > > --- a/kernel/events/core.c > > +++ b/kernel/events/core.c > > @@ -690,8 +690,8 @@ static void perf_ctx_disable(struct perf_event_context *ctx, bool cgroup) > > struct perf_event_pmu_context *pmu_ctx; > > > > list_for_each_entry(pmu_ctx, &ctx->pmu_ctx_list, pmu_ctx_entry) { > > - if (cgroup && !pmu_ctx->nr_cgroups) > > - continue; > > + // if (cgroup && !pmu_ctx->nr_cgroups) > > + // continue; > > perf_pmu_disable(pmu_ctx->pmu); > > } > > } > > @@ -701,8 +701,8 @@ static void perf_ctx_enable(struct perf_event_context *ctx, bool cgroup) > > struct perf_event_pmu_context *pmu_ctx; > > > > list_for_each_entry(pmu_ctx, &ctx->pmu_ctx_list, pmu_ctx_entry) { > > - if (cgroup && !pmu_ctx->nr_cgroups) > > - continue; > > + // if (cgroup && !pmu_ctx->nr_cgroups) > > + // continue; > > perf_pmu_enable(pmu_ctx->pmu); > > } > > } > > @@ -3307,8 +3307,8 @@ ctx_sched_out(struct perf_event_context *ctx, enum event_type_t event_type) > > is_active ^= ctx->is_active; /* changed bits */ > > > > list_for_each_entry(pmu_ctx, &ctx->pmu_ctx_list, pmu_ctx_entry) { > > - if (cgroup && !pmu_ctx->nr_cgroups) > > - continue; > > + // if (cgroup && !pmu_ctx->nr_cgroups) > > + // continue; > > __pmu_ctx_sched_out(pmu_ctx, is_active); > > } > > } > > > > > > The resulting profiling stats is similar to reverting f06cc667f79. Yeah, that's because you effectively reverted the change. :) > > I think there are some cases where pmu_ctx->nr_cgroups is zero but there is still cgroup event within, and some samples are missed, causing the stats changes, just a guess. I don't know what makes you think so. Do you see differences in the perf output? Any cgroup events having smaller number of samples or counts? Or was the fio benchmark degraded seriously? Thanks, Namhyung