Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3746715rdg; Wed, 18 Oct 2023 05:08:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGq6myTjXP2R3bZYdpa8PInEfw/Mz4b5D+Czyp+ipnsSn5a2PyjDbG8V6Df2d2jBmqW8siT X-Received: by 2002:a05:6a20:1589:b0:17a:f0e0:ed07 with SMTP id h9-20020a056a20158900b0017af0e0ed07mr5287348pzj.15.1697630885329; Wed, 18 Oct 2023 05:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697630885; cv=none; d=google.com; s=arc-20160816; b=W/vxe4p4AQonzor2bM2O0kkbM3IvSPIDEy9S/nh7cGZpWvqQjB1zAIwttg0b3ij/P7 8E2v9vWtvOFlovmgGeF6dZ2lx76ZfxljwzPT9uMVj46AA3zE8/Udak6N8DArzV+ZBP9T Y+li7e0nVTmhad5t9F/GUj+SVqytgQ2XEVWr8mk6u5GWzZzo2brqtqEzikaolTrsnZQi h/b62hdA5lLX+B3GgHw2H7M6LfWvEC1S7b582mhsXbEl05oF5SABVlUn05JZ+js3ngnp snWH1h6I9iiwlC/n0QbUGuXD4kDBtbuFtKtlHhfZjjd8DugXt9/NPSEYLgOnE6pGGTWN hHRQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=34canogPms5qIpzbgYLbZvTo7CKSJTUSgOrKFfdlG9Y=; fh=xuyB5/yxNx88JQ2zaYPvssnLcSwZFwKkfkWdocl+cWQ=; b=L3AhfsjFvcPLl/YhTRM7NOBx0tiIqWVmknDh+F5UMyIGr3c1NJRd7XvU5UKbYUxAaj tMjGG9hlb58wBuz4mCxSMSFrc/+bM4WLrOPzu3QjL29v1NFie2pfAbKyyxZ0SvpSVv7O QT7zleqEzqpGoXg3y9JA3c4D/1QSqeKmw/+e3MWMkyCvc3aCkql4tJkHuC4qrsAmEAwE xjbq3xlMFBOJej9mv0m6Z8lhH8dxsI+TbiEBwN06lWZDboxdcM0kr9Ej3nI/ZZS5FGlG xjLMQ2UNLGgCj+nmMJhS0yonr0GMtpj0H/O2auy9xYwltjcd3HThra+TbuNRUMcPBi7e B1eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=By2eJKRS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id q5-20020a170902dac500b001c60d1de681si210991plx.108.2023.10.18.05.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 05:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=By2eJKRS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 6ECEA811138C; Wed, 18 Oct 2023 05:08:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230272AbjJRMHx (ORCPT + 99 others); Wed, 18 Oct 2023 08:07:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230145AbjJRMHw (ORCPT ); Wed, 18 Oct 2023 08:07:52 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C78FDBA; Wed, 18 Oct 2023 05:07:49 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-9ae2cc4d17eso1093442866b.1; Wed, 18 Oct 2023 05:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697630868; x=1698235668; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=34canogPms5qIpzbgYLbZvTo7CKSJTUSgOrKFfdlG9Y=; b=By2eJKRShKymo7WV3jSvqvFWnzZDuPSFA26xMqTBjHG81J41yr6NOkz/aSmp2qOAvA FLp12btX/8mLsf2EZ/VyeWL24y1AhaM+KuMvPuTEwsgNW3DpjOaKIXXPH0oRKmkStO0L Mi55/ITRLDC7QJdprufhqwlSsHX6iRcPMlASjFDjBM45iQDMyLinmD26IFH9bKCq4y79 SGKoUp4dbMhmJ3ka5l9Tq56vfMMk8qWJp6gBLfblu9d5nsm7J+M2aVMftocCFJ2O9PPH +H/MU+ExnrsbiwIak88z4Je6pZArAJZLOM0cOPyh6nQ+K514W9otlm6mrnnVgAdz5dKs eErg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697630868; x=1698235668; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=34canogPms5qIpzbgYLbZvTo7CKSJTUSgOrKFfdlG9Y=; b=bQTiaiTb8Xw+diZAfo3I/G790XxYeBCw7TIwMUZ7qxADCciIOFrO315He3osyRfPKT pEe2eJDJ24W8VWlZLH4wW9BB1v4kc9fLsFXxLssNpbta086ZvT3dllyHH1mBt7s6+wqx rMKulYDFKGRAkw4t1romYpHMEu0o6TqzJ9/qIgkRnzVfrNJ4RErDHnfF0DnTCRJ4pU/6 AHRFJ7THaOrbhWol39mXOsEcpivECQpzVXzk0ZrOymU0SBH0Ks4YCDdyA/JZVaOXP6pW VTTWpaK98SdVMs/MRu+wADJ0UtnALpiYDygee5WeY7GZlFvasWf4FCTB0e8EugkTLatO fXMw== X-Gm-Message-State: AOJu0YxbbqssNOXF67w5xkRfSmq9W/dNmdFPbyDEbXASQvs4nGr/0ZsP 9Lw0DpKGkizzI/cXuxBoNHo= X-Received: by 2002:a17:906:c4c2:b0:9c6:1143:b73 with SMTP id cl2-20020a170906c4c200b009c611430b73mr2721811ejb.51.1697630867888; Wed, 18 Oct 2023 05:07:47 -0700 (PDT) Received: from gmail.com (1F2EF7B2.nat.pool.telekom.hu. [31.46.247.178]) by smtp.gmail.com with ESMTPSA id 27-20020a170906225b00b00997d76981e0sm1528584ejr.208.2023.10.18.05.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 05:07:47 -0700 (PDT) Sender: Ingo Molnar Date: Wed, 18 Oct 2023 14:07:45 +0200 From: Ingo Molnar To: Arnaldo Carvalho de Melo Cc: Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , Peter Zijlstra , LKML , linux-perf-users@vger.kernel.org Subject: Re: [perf stat] Extend --cpu to non-system-wide runs too? was Re: [PATCH v3] perf bench sched pipe: Add -G/--cgroups option Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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 fry.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 (fry.vger.email [0.0.0.0]); Wed, 18 Oct 2023 05:08:01 -0700 (PDT) * Arnaldo Carvalho de Melo wrote: > Em Tue, Oct 17, 2023 at 02:43:45PM +0200, Ingo Molnar escreveu: > > * Arnaldo Carvalho de Melo wrote: > > > Em Tue, Oct 17, 2023 at 01:40:07PM +0200, Ingo Molnar escreveu: > > > > Side note: it might make sense to add a sane cpumask/affinity setting > > > > option to perf stat itself: > > > > > perf stat --cpumask > > > > > ... or so? > > > > > We do have -C: > > > > > -C, --cpu list of cpus to monitor in system-wide > > > > > ... but that's limited to --all-cpus, right? > > > > > Perhaps we could extend --cpu to non-system-wide runs too? > > > > Maybe I misunderstood your question, but its a list of cpus to limit the > > > counting: > > > Ok. > > > So I thought that "--cpumask mask/list/etc" should simply do what 'taskset' > > is doing: using the sched_setaffinity() syscall to make the current > > workload and all its children. > > > There's impact on perf stat itself: it could just call sched_setaffinity() > > early on, and not bother about it? > > > Having it built-in into perf would simply make it easier to not forget > > running 'taskset'. :-) > > Would that be the only advantage? 1) Another advantage would be that perf stat could itself bind itself to the inverse affinity mask. This means the workload that is being executed is disturbed by perf as little as possible. That's not possible with 'taskset'. 2) Plus taskset's syntax is arguably silly: why does it need a separate -c option for a CPU list, why doesn't it figure it out by itself when there's a comma or dash in the mask string? A better syntax that perf could use would be to interpret it as a CPU mask only when presented with a '0x' or '0b' prefix for a binary mask which is IMO much more logical if we are talking masks. For example, to run on 8 full cores, using the '0b' GCC extension to specify binary literals: perf stat --cpus 0b101010101010101 'taskset' has other syntax idiosyncracies, such as the weird inverted argument order of PID and CPU list: kepler:~/tip> taskset -p $$ 0b101010101010101 taskset: invalid PID argument: '0b101010101010101' # .... erm, what?? # .... oh, taskset expects the PID argument last: kepler:~/tip> taskset -p 0b101010101010101 $$ pid 195878's current affinity mask: ffffffffffffffff pid 195878's new affinity mask: b101010101010101 # ... damn: taskset doesn't know the 0b prefix and blindly assumed it's # hexadecimal ... So I'd love it if perf stat grew a sane CPU-affinity option. 3) As a bonus perf stat could later also grow matching memory-node-affinity features that 'taskset' doesn't have ... Anyway, that's my attempt to convince you guys that it's a good idea to have this feature. :-) Thanks, Ingo