Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1723805rdb; Mon, 2 Oct 2023 21:11:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEBKLQC+yajzzFwb173CxnOqEq++vXuZPhYFQyLBqC701T+TRnV68HZhYZ/Na4MW2y48g3A X-Received: by 2002:a05:6a00:170a:b0:690:b7a1:ac51 with SMTP id h10-20020a056a00170a00b00690b7a1ac51mr14714035pfc.31.1696306275259; Mon, 02 Oct 2023 21:11:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696306275; cv=none; d=google.com; s=arc-20160816; b=dUW6ptL/B1PZkH8JcycsWu3PiKTOBbbJWabZLbAKuy9Cfx5JbOwB6SCmZ18wYHx6AQ A9TutsDdqexusPSWuU1DJ8cvFfHjB8AmqRMN+IXvag2ZqSm220Yd/xuhAUhnC3oLuD5q U/TZdS2DPCCVfghbi5KiqSfjARXbxm+hag7/cFYUYyU4y3eqyVLr7BY6rpG1pMaKmUUD 4yzQKcMNFs2Mta3l79u1dKg4y0Cc7mH+akUqb48daPdwrsPgB45gS9pSAcX8/EIKqc5x xGAN53fmmt6+3nNrGjymWbKK8XdVkT4b37k+GnDTDOuBDlFPfKv96N6zfVLf5udY0jQN lx7g== 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=kX2eQ1iGBH0QCf3TxKycUDyEpJrv7aT2BPHXDvTLH6Y=; fh=h6JXjo0SjP8WsG+Q8DS2FCDr5jzAkLaRBWw19YjW7ts=; b=IGROA79jnXPQlXP/lMPVGNI9TJxBzyweQ/+SxXeZTZI19D5SlASj60tcT7pFQAcP39 jlqxwVjgfWr97se4kKqNzAeUfCR3ua9VXrWxwZtc5cFofLEkchnRHm+hvt1CrXRcKMdH IYZmYYHLBmlmWifwtPkayMntHW+SkY56h7PpoH9rSE00r1pK63tJwsooB/Y20PSQA7mO jCVX9JFCjSVz6MIhTUKP6zVmIkrqmvBvh+HmcDJaHYzOjsNeqHM+4Eh2ZcdFQVT0AhBL FG+WccwUXvzYh+vnpz/Fy65ixlUR7VaMYMXCZ9vFSfxs2a2v98l0adkQZ8LGCTr3XtBI GSTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id a22-20020a637f16000000b0058934e7216dsi536146pgd.751.2023.10.02.21.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 21:11:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 0EFDB8027F06; Mon, 2 Oct 2023 21:11:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233697AbjJCELB convert rfc822-to-8bit (ORCPT + 99 others); Tue, 3 Oct 2023 00:11:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbjJCEK7 (ORCPT ); Tue, 3 Oct 2023 00:10:59 -0400 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92E8FA1; Mon, 2 Oct 2023 21:10:55 -0700 (PDT) Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3ae65e8eb45so316000b6e.1; Mon, 02 Oct 2023 21:10:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696306255; x=1696911055; 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=KtulQHPAbaWeljs345WA/V0ckv6ygveCfUecnvBzx/Y=; b=G6Xvutkr8alX72OsnQHL28HiVVfJP4wC0+yRhYWixab/Sr9L9Z+AiOypAh2o5TuhX8 27mYWQ83FdgFqJSt0C22Q0wpYnWT0MiGsq2D+jMaQUlynGEK2SNl5+6001lKMqyissvd rKsz8cMRpVd5ks7aqgh+k0MqTp73FlITwORr/4c9TeyuxkTUn78uiqnJrgkDnEFhGSkZ uET82NAFvTUMT6jrXoZ8JwsToK/1T7XHNcCnqqu7e2kbpqMe52ywuvemDAabsaP3uvP7 3jKcI2LT1pPYz7ZmdCM+wNwbj+6GdXOaCTkgR463p7RNzFlpC40XWFpQkyFenrH32eP5 R0hw== X-Gm-Message-State: AOJu0Ywt9gTNvY0llfd4cwf0kXDeLknYQT8MZ36yIphn+XzzBiiyvG4X JXMXgPYRvPeKFHSBQGDx3VJpRG596z6++cIsPAo= X-Received: by 2002:a05:6808:f90:b0:3af:9fc4:26c6 with SMTP id o16-20020a0568080f9000b003af9fc426c6mr2718038oiw.20.1696306254776; Mon, 02 Oct 2023 21:10:54 -0700 (PDT) MIME-Version: 1.0 References: <20230925062323.840799-1-irogers@google.com> In-Reply-To: From: Namhyung Kim Date: Mon, 2 Oct 2023 21:10:43 -0700 Message-ID: Subject: Re: [PATCH v1] perf pmus: Make PMU alias name loading lazy To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Leo Yan , Ravi Bangoria , James Clark , Kan Liang , 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.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Mon, 02 Oct 2023 21:11:13 -0700 (PDT) On Wed, Sep 27, 2023 at 10:19 PM Ian Rogers wrote: > > On Wed, Sep 27, 2023 at 10:00 PM Namhyung Kim wrote: > > > > Hi Ian, > > > > On Sun, Sep 24, 2023 at 11:24 PM Ian Rogers wrote: > > > > > > PMU alias names were computed when the first perf_pmu is created, > > > scanning all PMUs in event sources for a file called alias that > > > generally doesn't exist. Switch to trying to load the file when all > > > PMU related files are loaded in lookup. This would cause a PMU name > > > lookup of an alias name to fail if no PMUs were loaded, so in that > > > case all PMUs are loaded and the find repeated. The overhead is > > > similar but in the (very) general case not all PMUs are scanned for > > > the alias file. > > > > > > As the overhead occurs once per invocation it doesn't show in perf > > > bench internals pmu-scan. On a tigerlake machine, the number of openat > > > system calls for an event of cpu/cycles/ with perf stat reduces from > > > 94 to 69 (ie 25 fewer openat calls). > > > > I think the pmu-scan bench could show the difference as it > > calls perf_pmu__destroy() in the loop body. So every call to > > perf_pmu__scan() should start from nothing, right? > > The PMU alias name list was funny. It is/was maintained in the x86 > specific PMU code and the destroy didn't clear the list. This change > adds an openat to loading a PMU for the alias, so pmu-scan shows a > very small slow down. However, in the more normal cases we're reducing > the number of openats by 25%. I think that's ok. Applied to perf-tools-next, thanks!