Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v6] sched/cfs-scheduler: Fix 'make check' errors and warnings in hackbench.c
@ 2026-08-21  8:37 Samir Mulani
  2026-08-21 14:36 ` [LTP] " linuxtestproject.agent
  2026-08-25 14:11 ` [LTP] [PATCH v6] " Andrea Cervesato via ltp
  0 siblings, 2 replies; 4+ messages in thread
From: Samir Mulani @ 2026-08-21  8:37 UTC (permalink / raw)
  To: ltp; +Cc: Samir Mulani

Fix all 'make check' warnings in hackbench.c to comply with the LTP
coding style guidelines. Add the missing SPDX-License-Identifier
header and remove the unnecessary space after a cast as flagged by
checkpatch.pl. Make create_worker() and reap_worker() static since
both functions are only used within this translation unit.

Signed-off-by: Samir Mulani <samir@linux.ibm.com>
---
Changes in v6:
- Make create_worker() and reap_worker() static since both functions
  are only used within this translation unit.

Link: https://lore.kernel.org/ltp/20260407062336.127454-1-samir@linux.ibm.com/ #v1
Link: https://lore.kernel.org/ltp/20260412122842.1074017-1-samir@linux.ibm.com/ #v2
Link: https://lore.kernel.org/ltp/20260602095656.404290-1-samir@linux.ibm.com/ #v3
Link: https://lore.kernel.org/ltp/20260722114047.54671-1-samir@linux.ibm.com/ #v4
Link: https://lore.kernel.org/ltp/20260818113032.41963-1-samir@linux.ibm.com/ #v5

 .../kernel/sched/cfs-scheduler/hackbench.c    | 109 ++++++++----------
 1 file changed, 47 insertions(+), 62 deletions(-)

diff --git a/testcases/kernel/sched/cfs-scheduler/hackbench.c b/testcases/kernel/sched/cfs-scheduler/hackbench.c
index 6f37060aa..a9c3d2952 100644
--- a/testcases/kernel/sched/cfs-scheduler/hackbench.c
+++ b/testcases/kernel/sched/cfs-scheduler/hackbench.c
@@ -1,52 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /******************************************************************************/
-/* Copyright Rusty Russell,                                                   */
-/* Copyright Pierre Peiffer                                                   */
-/* Copyright Zhang, Yanmin,                                                   */
-/* Copyright Ingo Molnar,                                                     */
-/* Copyright Arjan van de Ven,                                                */
 /* Copyright (c) International Business Machines  Corp., 2008                 */
-/*                                                                            */
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software               */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    */
+/* Copyright Rusty Russell <rusty@rustcorp.com.au>                            */
+/* Copyright Pierre Peiffer <pierre.peiffer@bull.net>                         */
+/* Copyright Ingo Molnar <mingo@elte.hu>                                      */
+/* Copyright Arjan van de Ven <arjan@infradead.org>                           */
+/* Copyright Zhang, Yanmin <yanmin_zhang@linux.intel.com>                     */
+/* Copyright Nathan Lynch <ntl@pobox.com>                                     */
+/* Copyright Subrata Modak <subrata@linux.vnet.ibm.com>                       */
 /*                                                                            */
 /******************************************************************************/
 
 /******************************************************************************/
 /*                                                                            */
-/* File:        hackbench.c                                                   */
-/*                                                                            */
 /* Description: hackbench tests the Linux scheduler. Test groups of 20        */
-/*              processes spraying to 20 receivers                            */
-/*                                                                            */
-/* Total Tests: 1                                                             */
-/*                                                                            */
-/* Test Name:   hackbench01 and hackbench02                                   */
-/*                                                                            */
-/* Test Assertion:                                                            */
-/*                                                                            */
-/* Author(s):   Rusty Russell <rusty@rustcorp.com.au>,                        */
-/*              Pierre Peiffer <pierre.peiffer@bull.net>,                     */
-/*              Ingo Molnar <mingo@elte.hu>,                                  */
-/*              Arjan van de Ven <arjan@infradead.org>,                       */
-/*              "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>,               */
-/*              Nathan Lynch <ntl@pobox.com>                                  */
-/*                                                                            */
-/* History:     Included into LTP                                             */
-/*                  - June 26 2008 - Subrata Modak<subrata@linux.vnet.ibm.com>*/
+/*              processes spraying to 20 receivers.                           */
 /*                                                                            */
 /******************************************************************************/
 #include <pthread.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -59,24 +31,24 @@
 #include <sys/poll.h>
 #include <limits.h>
 
-#define SAFE_FREE(p) { if (p) { free(p); (p)=NULL; } }
+#define SAFE_FREE(p) { if (p) { free(p); (p) = NULL; } }
 #define DATASIZE 100
 static struct sender_context **snd_ctx_tab;	/*Table for sender context pointers. */
 static struct receiver_context **rev_ctx_tab;	/*Table for receiver context pointers. */
-static int gr_num = 0;		/*For group calculation */
+static int gr_num;		/*For group calculation */
 static unsigned int loops = 100;
 /*
  * 0 means thread mode and others mean process (default)
  */
 static unsigned int process_mode = 1;
 
-static int use_pipes = 0;
+static int use_pipes;
 
 struct sender_context {
 	unsigned int num_fds;
 	int ready_out;
 	int wakefd;
-	int out_fds[0];
+	int out_fds[];
 };
 
 struct receiver_context {
@@ -86,9 +58,15 @@ struct receiver_context {
 	int wakefd;
 };
 
-static void barf(const char *msg)
+static void barf(const char *fmt, ...)
 {
-	fprintf(stderr, "%s (error: %s)\n", msg, strerror(errno));
+	va_list ap;
+
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+
+	fprintf(stderr, " (error: %s)\n", strerror(errno));
 	exit(1);
 }
 
@@ -108,18 +86,18 @@ static void fdpair(int fds[2])
 		if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == 0)
 			return;
 	}
-	barf("Creating fdpair");
+	barf("%s: creating pipe pair", __func__);
 }
 
 /* Block until we're ready to go */
 static void ready(int ready_out, int wakefd)
 {
 	char dummy;
-	struct pollfd pollfd = {.fd = wakefd,.events = POLLIN };
+	struct pollfd pollfd = {.fd = wakefd, .events = POLLIN};
 
 	/* Tell them we're ready. */
 	if (write(ready_out, &dummy, 1) != 1)
-		barf("CLIENT: ready write");
+		barf("%s: pipe write", __func__);
 
 	/* Wait for "GO" signal */
 	if (poll(&pollfd, 1, -1) != 1)
@@ -182,7 +160,7 @@ again:
 	return NULL;
 }
 
-pthread_t create_worker(void *ctx, void *(*func) (void *))
+static pthread_t create_worker(void *ctx, void *(*func)(void *))
 {
 	pthread_attr_t attr;
 	pthread_t childid;
@@ -199,7 +177,7 @@ pthread_t create_worker(void *ctx, void *(*func) (void *))
 			exit(0);
 		}
 
-		return (pthread_t) 0;
+		return (pthread_t)0;
 	}
 
 	if (pthread_attr_init(&attr) != 0)
@@ -210,7 +188,9 @@ pthread_t create_worker(void *ctx, void *(*func) (void *))
 		barf("pthread_attr_setstacksize");
 #endif
 
-	if ((err = pthread_create(&childid, &attr, func, ctx)) != 0) {
+	err = pthread_create(&childid, &attr, func, ctx);
+
+	if (err != 0) {
 		fprintf(stderr, "pthread_create failed: %s (%d)\n",
 			strerror(err), err);
 		exit(-1);
@@ -218,7 +198,7 @@ pthread_t create_worker(void *ctx, void *(*func) (void *))
 	return (childid);
 }
 
-void reap_worker(pthread_t id)
+static void reap_worker(pthread_t id)
 {
 	int status;
 
@@ -235,15 +215,16 @@ void reap_worker(pthread_t id)
 }
 
 /* One group of senders and receivers */
-static unsigned int group(pthread_t * pth,
+static unsigned int group(pthread_t *pth,
 			  unsigned int num_fds, int ready_out, int wakefd)
 {
 	unsigned int i;
 	struct sender_context *snd_ctx = malloc(sizeof(struct sender_context) + num_fds * sizeof(int));
+
 	if (!snd_ctx)
 		barf("malloc()");
-	else
-		snd_ctx_tab[gr_num] = snd_ctx;
+
+	snd_ctx_tab[gr_num] = snd_ctx;
 
 	for (i = 0; i < num_fds; i++) {
 		int fds[2];
@@ -251,8 +232,8 @@ static unsigned int group(pthread_t * pth,
 
 		if (!ctx)
 			barf("malloc()");
-		else
-			rev_ctx_tab[gr_num * num_fds + i] = ctx;
+
+		rev_ctx_tab[gr_num * num_fds + i] = ctx;
 
 		/* Create the pipe between client and server */
 		fdpair(fds);
@@ -305,8 +286,12 @@ int main(int argc, char *argv[])
 		argv++;
 	}
 
-	if (argc >= 2 && (num_groups = atoi(argv[1])) == 0)
-		print_usage_exit();
+	if (argc >= 2) {
+		num_groups = atoi(argv[1]);
+
+		if (num_groups == 0)
+			print_usage_exit();
+	}
 
 	printf("Running with %d*40 (== %d) tasks.\n",
 	       num_groups, num_groups * 40);
@@ -329,7 +314,7 @@ int main(int argc, char *argv[])
 	snd_ctx_tab = malloc(num_groups * sizeof(void *));
 	rev_ctx_tab = malloc(num_groups * num_fds * sizeof(void *));
 	if (!pth_tab || !snd_ctx_tab || !rev_ctx_tab)
-		barf("main:malloc()");
+		barf("%s: malloc()", __func__);
 
 	fdpair(readyfds);
 	fdpair(wakefds);
@@ -363,9 +348,9 @@ int main(int argc, char *argv[])
 
 	/* free the memory */
 	for (i = 0; i < num_groups; i++) {
-		for (j = 0; j < num_fds; j++) {
-			SAFE_FREE(rev_ctx_tab[i * num_fds + j])
-		}
+		for (j = 0; j < num_fds; j++)
+			SAFE_FREE(rev_ctx_tab[i * num_fds + j]);
+
 		SAFE_FREE(snd_ctx_tab[i]);
 	}
 	SAFE_FREE(pth_tab);
-- 
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] sched/cfs-scheduler: Fix 'make check' errors and warnings in hackbench.c
  2026-08-21  8:37 [LTP] [PATCH v6] sched/cfs-scheduler: Fix 'make check' errors and warnings in hackbench.c Samir Mulani
@ 2026-08-21 14:36 ` linuxtestproject.agent
  2026-08-25 14:11 ` [LTP] [PATCH v6] " Andrea Cervesato via ltp
  1 sibling, 0 replies; 4+ messages in thread
From: linuxtestproject.agent @ 2026-08-21 14:36 UTC (permalink / raw)
  To: Samir Mulani; +Cc: ltp

Hi Samir,

On Fri, 21 Aug 2026, Samir Mulani wrote:
> sched/cfs-scheduler: Fix 'make check' errors and warnings in hackbench.c

> Fix all 'make check' warnings in hackbench.c to comply with the LTP
> coding style guidelines.

Could the remaining hackbench.c warnings be fixed, or could the subject and
body clarify that this patch only addresses checkpatch style findings?

The configured targeted `make check` still reports a signed/unsigned
comparison in sender(), an implicit fallthrough in create_worker(), and an
uninitialized byte passed to write() in ready().

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH v6] sched/cfs-scheduler: Fix 'make check' errors and warnings in hackbench.c
  2026-08-21  8:37 [LTP] [PATCH v6] sched/cfs-scheduler: Fix 'make check' errors and warnings in hackbench.c Samir Mulani
  2026-08-21 14:36 ` [LTP] " linuxtestproject.agent
@ 2026-08-25 14:11 ` Andrea Cervesato via ltp
  2026-09-10 17:17   ` Samir M
  1 sibling, 1 reply; 4+ messages in thread
From: Andrea Cervesato via ltp @ 2026-08-25 14:11 UTC (permalink / raw)
  To: Samir Mulani; +Cc: ltp

Hi Samir,

mmh..I was about to merge this patch, but then I realized that
this was applied on a old API test, which is going to be
rewritten anyway into the new API. For this reason, I'm not
sure anymore if it's the case we are merging it.

Are you planning to rewrite the code into the new LTP API?

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH v6] sched/cfs-scheduler: Fix 'make check' errors and warnings in hackbench.c
  2026-08-25 14:11 ` [LTP] [PATCH v6] " Andrea Cervesato via ltp
@ 2026-09-10 17:17   ` Samir M
  0 siblings, 0 replies; 4+ messages in thread
From: Samir M @ 2026-09-10 17:17 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi Andrea,

On 25/08/26 7:41 pm, Andrea Cervesato wrote:
> Hi Samir,
>
> mmh..I was about to merge this patch, but then I realized that
> this was applied on a old API test, which is going to be
> rewritten anyway into the new API. For this reason, I'm not
> sure anymore if it's the case we are merging it.
>
> Are you planning to rewrite the code into the new LTP API?
Yes, I’m planning to rewrite it using the new LTP API and will send an 
updated patch for review.
Thanks for pointing this out.

> --
> Andrea Cervesato
> SUSE QE Automation Engineer Linux
> andrea.cervesato@suse.com
Best regards,
Samir

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-10 17:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21  8:37 [LTP] [PATCH v6] sched/cfs-scheduler: Fix 'make check' errors and warnings in hackbench.c Samir Mulani
2026-08-21 14:36 ` [LTP] " linuxtestproject.agent
2026-08-25 14:11 ` [LTP] [PATCH v6] " Andrea Cervesato via ltp
2026-09-10 17:17   ` Samir M

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox