Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2191385rdb; Tue, 3 Oct 2023 13:08:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH99CgCVpvZZgxlNgbGLDnhZWCTyHBp+vMidqpw2EiYudkq0kXirX0osZT4cG+XVrE2fFWs X-Received: by 2002:a05:6808:491:b0:3a9:9bb6:7fe with SMTP id z17-20020a056808049100b003a99bb607femr542451oid.21.1696363703210; Tue, 03 Oct 2023 13:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696363703; cv=none; d=google.com; s=arc-20160816; b=dmM4gWkfcdR0DO4zD5vvUIMWUtAixEfx6vnfylWNDq7XNwpfr6t7Ef4ElymgsiIC6X F9KY+DCL9FrUFN42xZOVw3dBXRrdGx90dY/UFNxJYVQHX9lKIlC0bxCBJDm0jnR1fpL6 bMwfI7smreRLqipgIdII5Z2WJkrd81fktdpfnSF/luUBRs+QpZbqlB2vpAtj7JlCWELf 7UrCjRYuHqPCiz6d+B1kRpa8OpWDLaNW5TfpZgu7EuLTRhoRtUoQECBsFPBhiyo4dJXK d6Q8mWEGKv9LWbf/RGjJndt3kpKbvqCkwKO9JKhLls4EWug6J/yP9bFHGc5JKNdBgwhn jYNw== 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=ZPQ57UjeayKvNlgKhI+gEXBS3sqfquHaQurc48V4wBI=; fh=/kGTXW1xJxXClMFWqs8nGLRWfZYmTl9eRB18gOyxSPo=; b=V+HtoiBeDdZim+DR+Gkhc2qyQNsi3juea1YMmesrDEfbCFcpPnwmaTOra+PMqq0Nft 45lgyXDQ8Id576cr71+HyCDJxUEBz093iHBkUSqY5Yjx3q0THKAHU33ujA3FNemZDOo4 Zc5HUfgjOI2PFkfDqDr1UCzVoElqVPP52nqTlk57cxKdqskBeQ6gTm+taL5h8J9li/fC arP+DcmQMzdstQCYWBFQTPihPwgLA2+61pvGpJwa5ACBxAdnfZZKXvGPE8fsSCLT2HXT C6wnXbj8Z/k21xeK9u71XZRZycdjrq4Arh5RVmj+AM1lEwtEfMjhfkvcL/tiK3TM1Up4 VdwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id 81-20020a630254000000b00578cc82870asi2086428pgc.344.2023.10.03.13.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 13:08:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 4C59481972F8; Tue, 3 Oct 2023 13:08:20 -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 S241024AbjJCUIP convert rfc822-to-8bit (ORCPT + 99 others); Tue, 3 Oct 2023 16:08:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241026AbjJCUIO (ORCPT ); Tue, 3 Oct 2023 16:08:14 -0400 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8BAEA1; Tue, 3 Oct 2023 13:08:11 -0700 (PDT) Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3af5fd13004so906256b6e.0; Tue, 03 Oct 2023 13:08:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696363691; x=1696968491; 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=1L7JTll2iZg4TpN2jgrHscBi0WZs33vPmuyNsxvOfNo=; b=AzRUI7/xe+MXKnw/KPJVUJ0A58df4gaRkpqRfkAE0fC3qBv/gJSerUruTAusqRnLHS SfgNDpoGLFTKmJbouBOQt4Ykvk3hMoj9lx6DH4jvao0cXGOV169eJK04yUarxOfBOxbw mZ4ewM4CitGGrgmv4Sa5oKDjmODmTj2jpg5pPa9oJ6Je3ir4VGg5dUvUP6JJiCEJ9tLL 5OVeeefzQEv235+y4UD56cwEQh5lry0n3D7zfYedJYvwwabuJJOBTftMukZVUAgyY0I8 vSA/R6IcT8hp2/tUVp902MMpwXv33P2KPMUuT1uVZsF/yZRHXGsdyJKAxWcn+k6MZiu8 +KOQ== X-Gm-Message-State: AOJu0YzkhuxkS7wBOVFouyzUhUqMA7Bv6yEQ77hm+vvDB/ypKbSdTePI kK5lwkbOpHkFHikYClLxxwRakx12ToFDZoMyzuE= X-Received: by 2002:a05:6808:1b1f:b0:3ae:2877:9b31 with SMTP id bx31-20020a0568081b1f00b003ae28779b31mr652430oib.20.1696363690891; Tue, 03 Oct 2023 13:08:10 -0700 (PDT) MIME-Version: 1.0 References: <20230916040915.1075620-1-irogers@google.com> In-Reply-To: From: Namhyung Kim Date: Tue, 3 Oct 2023 13:07:59 -0700 Message-ID: Subject: Re: [PATCH v1] perf evlist: Avoid frequency mode for the dummy event To: Mingwei Zhang Cc: Ian Rogers , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Yang Jihong , Stephane Eranian 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]); Tue, 03 Oct 2023 13:08:20 -0700 (PDT) Hello, On Wed, Sep 20, 2023 at 10:05 PM Mingwei Zhang wrote: > > On Mon, Sep 18, 2023 at 3:43 PM Ian Rogers wrote: > > > > On Sat, Sep 16, 2023 at 5:46 PM Mingwei Zhang wrote: > > > Thank you very much for the change. I have one quick question about > > > the PMU unthrottling logic. When I am looking into the function > > > perf_adjust_freq_unthr_context(), I see the loop with PMU stop and > > > start in each iteration. Is there a good way to avoid this PMU reset > > > operation while quickly figuring out the event in frequency mode? > > > > Agreed. I think before the pmu_disable could be avoided for this condition: > > ``` > > if (event->hw.interrupts != MAX_INTERRUPTS && > > (!event->attr.freq || !event->attr.sample_freq)) > > continue; > > ``` > > Fixing up the event stop/start looks harder. > > > > Right, I think putting the check early before pmu_disable() is already > a great optimization. The only concern I initially had was whether > event->hw.interrupts can be accessed before we disable the pmu. But > after checking this field in other locations, I don't see any problem > at all. The event->hw.interrupts would be increased in the NMI handler so there is a race between the check and the NMI. That's why I think it checks that after disabling the PMU. But I think we can skip non-sampling events for sure. Then it would be better to set attr.sample_period = 0 rather than attr.freq. if (!is_sampling_event(event)) continue; perf_pmu_disable(event->pmu); ... Thanks, Namhyung