Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2655084rwo; Sun, 23 Jul 2023 21:40:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlGWvVzIPlEFHjM/oVD0LvUVIAUT7THzV0Q/jNLCHIhKPUeHumJ73HKDYxOaSauq4cptzXEc X-Received: by 2002:a17:907:d24:b0:98e:3dac:6260 with SMTP id gn36-20020a1709070d2400b0098e3dac6260mr17626955ejc.13.1690173640327; Sun, 23 Jul 2023 21:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690173640; cv=none; d=google.com; s=arc-20160816; b=XQTA9g7+dGrXTb7lTfS61FMs3Fghnko99HqSqB/eAld746Vn+QSxGvMSUArv+/ZDPK YApSceIowK6kyBezU26FL7IOH3jotiA7JKrppJ5BfUT5hMdIbixs0w7o+ISKN8ftHxjM Inbdj/wqvXuNM6efMzuc4BjYbO/Un6+GIzd70EH0ZheWoDycv8LdjtP66ATnEWYBwTyi j7ysLnHRUOXBoAdqS+nxCGIpEF10KE2CAnQZQZp/KZ3SyP01qjdejWOUYKK+F2hIuzL6 23saWf06cgxDWrRrE5/AAkd89DaVp6lZclVb45/jiPO5JsyyRraF+ezv0w3AHzOaeqjJ MZvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=e13gg+tQ7xJx7Ca2TohrTUlvLZDKhJy9J/hQPJgMTwU=; fh=v4ikAZ0a98zNYtIGEr7cHO7X8Cd5q2rhXLtbB3SKUUo=; b=RglMYinSH7dF55IAF/vxdy9zYjAE0lSiSV+OCeW/mwcyG7n3SM8IRvWfTrGbsnOmGR br1JRFCtCcukmIF7qtF64TYoOHFUUZm4k1LIylYNwawceIIuWv49HwxXd0jni3dw0i64 vS9z0er+1UzaclHOsb/V59vYQiSBAzPPulgBoS2XK9ofc5MNaFuGW33qmqCgKN0FTABI 3zq0Qjur7dLrxx+hQhZQqIZhoVRItEarwEfp+ZVKDQV4KqS9Vewc5o5WDO0diEsGWO6J ElL+T3POj9Ny661a6BoUALv3/a+3dZ3joY7i94PMCTZGczojUtvvVYzl7eb2MHonqVL5 UPQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lx19-20020a170906af1300b00983f3f76dd0si6160391ejb.155.2023.07.23.21.40.15; Sun, 23 Jul 2023 21:40:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbjGXDud (ORCPT + 99 others); Sun, 23 Jul 2023 23:50:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjGXDua (ORCPT ); Sun, 23 Jul 2023 23:50:30 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D9483; Sun, 23 Jul 2023 20:50:27 -0700 (PDT) Received: from kwepemi500013.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R8R3V26V0zVjfm; Mon, 24 Jul 2023 11:48:54 +0800 (CST) Received: from M910t (10.110.54.157) by kwepemi500013.china.huawei.com (7.221.188.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 24 Jul 2023 11:50:23 +0800 Date: Mon, 24 Jul 2023 11:50:06 +0800 From: Changbin Du To: Ian Rogers CC: Changbin Du , Adrian Hunter , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , , Subject: Re: [PATCH] perf: add new option '--workload-attr' to set workload sched_policy/priority/mask Message-ID: <20230724035006.5vje3jzhmedyljas@M910t> References: <20230713085831.395112-1-changbin.du@huawei.com> <20230714071914.3jro4kfcvhun2ptd@M910t> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Originating-IP: [10.110.54.157] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500013.china.huawei.com (7.221.188.120) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Wed, Jul 19, 2023 at 09:55:39AM -0700, Ian Rogers wrote: > On Fri, Jul 14, 2023 at 12:19 AM Changbin Du wrote: > > > > On Fri, Jul 14, 2023 at 10:06:31AM +0300, Adrian Hunter wrote: > > > On 13/07/23 11:58, Changbin Du wrote: > > > > To get consistent benchmarking results, sometimes we need to set the > > > > sched_policy/priority/mask of the workload to reduce system noise. > > > > > > > > For example, CPU binding is required on big.little system. > > > > > > > > $ perf stat -r 10 -- taskset -c 0 ls > > > > > > > > Nevertheless, the 'taskset' is also counted here. > > > > > > > > To get away of the middleman, this adds a new option '--workload-attr' to > > > > do the same jobs for stat and record commands. > > > > > > > > $ sudo perf stat --workload-attr fifo,40,0x1 -- ls > > > > > > > > Above will make 'ls' run on CPU #0 with fifo scheduler and realtime > > > > priority is 40. > > > > > > Aren't there ways to set up a process then start perf using -p > > > then let the process continue. > > > > > By that you need a mechanism to pause the new spawnned process and wait perf to > > attach. Or setup the sched properties by the app itself. But sometimes we just > > simply want to run the app through and measure some events. With > > --workload-attr, we do not need extra setup works. > > To my naive eyes this looks to be a broadly useful addition. Some thoughts: > - "cpu-mask" as the command line argument name, this is "-C" and > "--cpu" elsewhere, so perhaps just "cpu" as the mask is perhaps > confusing. I changed the name of third field to cpu-list, and use perf_cpu_map_new() to parse the list. This api doesn't accept a mask. --workload-attr setup target workload (the ) attributes: sched_policy: other|fifo|rr|batch|idle priority: scheduling priority for fifo|rr, nice value for other cpu-list: CPU affinity. e.g. 1-2:4 is processors #1, #2, and #4 > - could we get a test? Perhaps add a case to tools/perf/tests/shell/stat.sh: > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/tests/shell/stat.sh?h=perf-tools-next > No problem, I will add a testcase there. > Thanks, > Ian > > > -- > > Cheers, > > Changbin Du -- Cheers, Changbin Du