Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2116297rdg; Sun, 15 Oct 2023 11:54:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7nIuHm58gv/BBlbfvVp2O0/XdLm/2hnk6L8JgEtou/nv6zQ39TVuq/u7SixnrLOnxBnZ+ X-Received: by 2002:a05:6359:6b8e:b0:166:9c14:a838 with SMTP id ta14-20020a0563596b8e00b001669c14a838mr6734322rwb.19.1697396061094; Sun, 15 Oct 2023 11:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697396061; cv=none; d=google.com; s=arc-20160816; b=PrLNRQ89cykc2lTU546hyaCx5bXc/lZTaibNq8pWldm5eVEvKBcx1LK5WbnAOhfZ94 ZHUDizY9M5l6fxWM1PsUpP7pLqm9JiCCpQABxVyyQ5RT3RfIiK1H2MjvEnHUktVstB/z k0sqG/HMMnIRRoEGotbXOuxN03wHqcBZmai2lL8fTocWIIwt1VQrSPsVeo2cw9991aiE t077JFe45ndQDrgHZ1OcYXimrXw0RgrL8uOMt13yrM1lVFrx8PobGZ5g8EzYpeeqay+Q 9ouK4QbXnOT4h1ZNkZQjxLMnGVf8NsCNXfGo4lfPPsB14LoZfoJyNBesYhIo2D7/wtMc NnqA== 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=NKevBHGuaMCBix+5XEWZl++/DNLA6wQ8voj8wy8eGF0=; fh=vrfuuNzjS9h0ubk9/JvKU83fDDS97e1ldMOTHbHMWxY=; b=AMLmDcfGYdBZ/6R3wqIfRU0zHT+7xR0kPie+3ps/ZRPsQLdQo7l6sOe9ygrSUWy3ze k5Mm7lRUcBWBq3rQdAQoHei2j1cX7Oc7UoComsfXlaH01r3BBzTO1Ujnt3SSP3fWJdYM PAo7Awp1OdVIX9DpA/T0td7eUdFx39WUVVwJ24tiKAoDbuLWRGaIM2QeCRMwGOzZ9ED6 667yWJZbq832NkARD/SL5v3pOlf2HwTAGyuM8vIDfwdl2tmI3QIMyeCe7bOvxFRuSygY +b3ynrpg2iOHOycK2kK4eFkiiqenKk78wtztcW0+OZ9zRpqJ9LmCHKNjq8kYGfRga+SE EZhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id w8-20020a056a0014c800b0068fac3509a9si21705914pfu.350.2023.10.15.11.54.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 11:54:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id E0D1E8058B54; Sun, 15 Oct 2023 11:54:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230153AbjJOSyA convert rfc822-to-8bit (ORCPT + 99 others); Sun, 15 Oct 2023 14:54:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjJOSyA (ORCPT ); Sun, 15 Oct 2023 14:54:00 -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 D5595A9; Sun, 15 Oct 2023 11:53:58 -0700 (PDT) Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3b2b1b25547so1493621b6e.3; Sun, 15 Oct 2023 11:53:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697396035; x=1698000835; 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=2G81DqXs3X1Zjdsq9mf6OJafYAWE3ifxu15bBycQsx0=; b=ZIQdbTq6V0lh1rCrIEysHM8lL3OVjgOJOKyafMgnLnoMtbDMpSIy+eSGEhW9q7G8WS KJ5ng4CYaZfHEdySjUbBrjDXrds94MpoXm5Ks1a/S7J6tnr5pTpyaFGAmde42GFHy/U8 Vtr0KlQEpM+Nu9RuuoJt9j24NiNRYF+wnWfe4ZSpfvpczLtpxrmEDtAXSg5eA4v/mNTX LP8xiKupOIhMMetMXRIwS1LBjzgwBRRwVWHO0sENpkRrC9kzqlcKBc8/GbWgg6HMr5xj ixJFhcKi/6IzaPYI01jBDw0m66rYE0VAJr8F7hXH4N7c17veFRXblKP3iyPkUKlgxnOf 3Qdg== X-Gm-Message-State: AOJu0YwT0jwDdGp6cIdul3BYN4rGWzxE252mziLJXQxisAPCLl3FgRfI dyJXoVER2BEgWJdIst6BRFNHmE8F8n/dU7Rc7hg= X-Received: by 2002:a05:6808:1146:b0:3ae:156f:d312 with SMTP id u6-20020a056808114600b003ae156fd312mr52398901oiu.34.1697396035616; Sun, 15 Oct 2023 11:53:55 -0700 (PDT) MIME-Version: 1.0 References: <20231013232435.1012585-1-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Sun, 15 Oct 2023 11:53:44 -0700 Message-ID: Subject: Re: [PATCH v2] perf bench sched pipe: Add -G/--cgroups option To: Ingo Molnar Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Ian Rogers , Adrian Hunter , Peter Zijlstra , LKML , linux-perf-users@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 agentk.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 (agentk.vger.email [0.0.0.0]); Sun, 15 Oct 2023 11:54:19 -0700 (PDT) On Sat, Oct 14, 2023 at 1:44 AM Ingo Molnar wrote: > > > * Namhyung Kim wrote: > > > + cgrp_send = cgroup__new(p, /*do_open=*/true); > > + if (cgrp_send == NULL) { > > + fprintf(stderr, "cannot open sender cgroup: %s", p); > > + goto out; > > + } > > Maybe in this case print out a small suggestion of how to create this > particular cgroup? > > Most distro users and even kernel developers don't ever have to create > new cgroups. > > Maybe even allow the creation of new cgroups for this testing, if they > don't already exist? As long as we don't delete any cgroups I don't think > much harm can be done - and the increase in usability is substantial. I'm not sure if it's ok create a new cgroup and leave it after the use. Anyway, none of the existing subcommands create new cgroups IIUC and I think it'd be ok to print a message on how to create one. > > > +static void enter_cgroup(struct cgroup *cgrp) > > +{ > > + char buf[32]; > > + int fd, len; > > + pid_t pid; > > + > > + if (cgrp == NULL) > > + return; > > + > > + if (threaded) > > + pid = syscall(__NR_gettid); > > + else > > + pid = getpid(); > > + > > + snprintf(buf, sizeof(buf), "%d\n", pid); > > + len = strlen(buf); > > + > > + /* try cgroup v2 interface first */ > > + if (threaded) > > + fd = openat(cgrp->fd, "cgroup.threads", O_WRONLY); > > + else > > + fd = openat(cgrp->fd, "cgroup.procs", O_WRONLY); > > + > > + /* try cgroup v1 if failed */ > > + if (fd < 0) > > + fd = openat(cgrp->fd, "tasks", O_WRONLY); > > + > > + if (fd < 0) { > > + printf("failed to open cgroup file in %s\n", cgrp->name); > > + return; > > + } > > + > > + if (write(fd, buf, len) != len) > > + printf("cannot enter to cgroup: %s\n", cgrp->name); > > The failures here should probably result in termination of the run with an > error code, not just messages which are easy to skip in automated tests? Right, I'll make the change. Thanks, Namhyung