From patchwork Wed Jan 19 15:57:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12717634 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60364C433EF for ; Wed, 19 Jan 2022 15:57:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355875AbiASP5p (ORCPT ); Wed, 19 Jan 2022 10:57:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242656AbiASP5o (ORCPT ); Wed, 19 Jan 2022 10:57:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66AC1C06161C for ; Wed, 19 Jan 2022 07:57:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 074A161535 for ; Wed, 19 Jan 2022 15:57:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7036EC340E5; Wed, 19 Jan 2022 15:57:43 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1nADLC-007PZi-7P; Wed, 19 Jan 2022 10:57:42 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (Google)" , Tzvetomir Stoyanov Subject: [PATCH 1/4] libtracefs: Add the get_affinity functions to the main libtracefs man page Date: Wed, 19 Jan 2022 10:57:38 -0500 Message-Id: <20220119155741.1766541-2-rostedt@goodmis.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220119155741.1766541-1-rostedt@goodmis.org> References: <20220119155741.1766541-1-rostedt@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (Google)" The main libtracefs man page should contain all the available API functions. Link: https://lore.kernel.org/all/CAPpZLN4n=L-ZHCXM+LDRiQu0XwR4iCnGeCKJOuOWenkz2EhESA@mail.gmail.com/ Reported-by: Tzvetomir Stoyanov Signed-off-by: Steven Rostedt (Google) --- Documentation/libtracefs.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/libtracefs.txt b/Documentation/libtracefs.txt index e7eb090b8268..33988007d865 100644 --- a/Documentation/libtracefs.txt +++ b/Documentation/libtracefs.txt @@ -35,6 +35,9 @@ Trace instances: int *tracefs_instance_set_affinity*(struct tracefs_instance pass:[*]_instance_, const char pass:[*]_cpu_str_); int *tracefs_instance_set_affinity_set*(struct tracefs_instance pass:[*]_instance_, cpu_set_t pass:[*]_set_, size_t _set_size_); int *tracefs_instance_set_affinity_raw*(struct tracefs_instance pass:[*]_instance_, const char pass:[*]_mask_); + char pass:[*]*tracefs_instance_get_affinity*(struct tracefs_instance pass:[*]_instance_); + int *tracefs_instance_get_affinity_set*(struct tracefs_instance pass:[*]_instance_, cpu_set_t pass:[*]_set_, size_t _set_size_); + char pass:[*]*tracefs_instance_get_affinity_raw*(struct tracefs_instance pass:[*]_instance_); Trace events: char pass:[*]pass:[*]*tracefs_event_systems*(const char pass:[*]_tracing_dir_); From patchwork Wed Jan 19 15:57:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12717633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89991C433FE for ; Wed, 19 Jan 2022 15:57:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242656AbiASP5p (ORCPT ); Wed, 19 Jan 2022 10:57:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355867AbiASP5o (ORCPT ); Wed, 19 Jan 2022 10:57:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69674C06173E for ; Wed, 19 Jan 2022 07:57:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0731961534 for ; Wed, 19 Jan 2022 15:57:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F075C340E1; Wed, 19 Jan 2022 15:57:43 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1nADLC-007PZl-85; Wed, 19 Jan 2022 10:57:42 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (Google)" , Tzvetomir Stoyanov Subject: [PATCH 2/4] libtracefs: Fix typos and grammar in get_affinity man page Date: Wed, 19 Jan 2022 10:57:39 -0500 Message-Id: <20220119155741.1766541-3-rostedt@goodmis.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220119155741.1766541-1-rostedt@goodmis.org> References: <20220119155741.1766541-1-rostedt@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (Google)" There were some mistakes in the man page for the get_affinity() API functions. Fix them. Link: https://lore.kernel.org/all/CAPpZLN4n=L-ZHCXM+LDRiQu0XwR4iCnGeCKJOuOWenkz2EhESA@mail.gmail.com/ Reported-by: Tzvetomir Stoyanov Signed-off-by: Steven Rostedt (Google) --- Documentation/libtracefs-instances-affinity.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/libtracefs-instances-affinity.txt b/Documentation/libtracefs-instances-affinity.txt index 0f3093d62035..107334dd1298 100644 --- a/Documentation/libtracefs-instances-affinity.txt +++ b/Documentation/libtracefs-instances-affinity.txt @@ -24,7 +24,7 @@ char pass:[*]*tracefs_instance_get_affinity_raw*(struct tracefs_instance pass:[* DESCRIPTION ----------- -These functions set or retrieves the CPU affinity that limits what CPUs will have tracing enabled +These functions set or retrieve the CPU affinity that limits what CPUs will have tracing enabled for a given instance defined by the _instance_ parameter. If _instance_ is NULL, then the top level instance is affected. @@ -71,7 +71,7 @@ RETURN VALUE ------------ All the set functions return 0 on success and -1 on error. -The functinos *tracefs_instance_get_affinity()* and *tracefs_instance_get_affinity_raw()* +The functions *tracefs_instance_get_affinity()* and *tracefs_instance_get_affinity_raw()* returns an allocated string that must be freed with *free*(3), or NULL on error. The function *tracefs_instance_get_affinity_set()* returns the number of CPUs that From patchwork Wed Jan 19 15:57:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12717637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 285FFC43217 for ; Wed, 19 Jan 2022 15:57:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355985AbiASP5r (ORCPT ); Wed, 19 Jan 2022 10:57:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355984AbiASP5r (ORCPT ); Wed, 19 Jan 2022 10:57:47 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03565C06161C for ; Wed, 19 Jan 2022 07:57:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 54487CE1C72 for ; Wed, 19 Jan 2022 15:57:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DDA0C340E8; Wed, 19 Jan 2022 15:57:43 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1nADLC-007PZo-8m; Wed, 19 Jan 2022 10:57:42 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (Google)" , Tzvetomir Stoyanov Subject: [PATCH 3/4] libtracefs: Fix grammar in tracefs_instance_get_affinity() comment Date: Wed, 19 Jan 2022 10:57:40 -0500 Message-Id: <20220119155741.1766541-4-rostedt@goodmis.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220119155741.1766541-1-rostedt@goodmis.org> References: <20220119155741.1766541-1-rostedt@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (Google)" There was a grammar mistake in the comment describing the tracefs_instance_get_affinity() function. Fix it. Link: https://lore.kernel.org/all/CAPpZLN4n=L-ZHCXM+LDRiQu0XwR4iCnGeCKJOuOWenkz2EhESA@mail.gmail.com/ Reported-by: Tzvetomir Stoyanov Signed-off-by: Steven Rostedt (Google) --- src/tracefs-instance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c index 2d825b0e3bd0..db51af3818f0 100644 --- a/src/tracefs-instance.c +++ b/src/tracefs-instance.c @@ -1112,7 +1112,7 @@ static inline int update_cpu(int cpus, int cpu_set, int cpu, int s, char **set) * If no CPUs are set, an empty string is returned "\0", and it too needs * to be freed. * - * Returns an allocate string containing the CPU affinity in "human readable" + * Returns an allocated string containing the CPU affinity in "human readable" * format which needs to be freed with free(), or NULL on error. */ char *tracefs_instance_get_affinity(struct tracefs_instance *instance) From patchwork Wed Jan 19 15:57:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 12717635 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61A87C43219 for ; Wed, 19 Jan 2022 15:57:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355984AbiASP5s (ORCPT ); Wed, 19 Jan 2022 10:57:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355867AbiASP5r (ORCPT ); Wed, 19 Jan 2022 10:57:47 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2DE9C061574 for ; Wed, 19 Jan 2022 07:57:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 6B9FFCE1D3F for ; Wed, 19 Jan 2022 15:57:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71468C340E6; Wed, 19 Jan 2022 15:57:43 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.95) (envelope-from ) id 1nADLC-007PZr-9R; Wed, 19 Jan 2022 10:57:42 -0500 From: Steven Rostedt To: linux-trace-devel@vger.kernel.org Cc: "Steven Rostedt (Google)" , Tzvetomir Stoyanov Subject: [PATCH 4/4] libtracefs: Do not count CPUs beyond set size in get_affinity Date: Wed, 19 Jan 2022 10:57:41 -0500 Message-Id: <20220119155741.1766541-5-rostedt@goodmis.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220119155741.1766541-1-rostedt@goodmis.org> References: <20220119155741.1766541-1-rostedt@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org From: "Steven Rostedt (Google)" If the string of CPUs has bits set that are beyond the size that the passed in cpu_set_t size can hold, do not set them. This relies on the _S version of the CPU_SET macros from not crashing if the size if too big. One would think that the _S versions would be made specifically to protect against being too big. If a CPU is set in the string but is outside the size limit of the cpu_set_t passed in, then do not add it to the count that is returned by tracefs_instance_get_affinity_set(). Link: https://lore.kernel.org/all/CAPpZLN4n=L-ZHCXM+LDRiQu0XwR4iCnGeCKJOuOWenkz2EhESA@mail.gmail.com/ Reported-by: Tzvetomir Stoyanov Signed-off-by: Steven Rostedt (Google) --- src/tracefs-instance.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c index db51af3818f0..1493938fa445 100644 --- a/src/tracefs-instance.c +++ b/src/tracefs-instance.c @@ -1000,7 +1000,16 @@ static inline int update_cpu_set(int cpus, int cpu_set, int cpu, return 0; CPU_SET_S(cpu_set + cpu, set_size, set); - return 1; + + /* + * It is possible that the passed in set_size is not big enough + * to hold the cpu we just set. If that's the case, do not report + * it as being set. + * + * The CPU_ISSET_S() should return false if the CPU given to it + * is bigger than the set itself. + */ + return CPU_ISSET_S(cpu_set + cpu, set_size, set) ? 1 : 0; } /**