Skip to contentSkip to conversation

cfs-scheduler: Fixed "make check" errors and warnings.

PATCH Superseded Samir 2 participants 3 messages Apr 12 – May 6

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Samir

author
#0 lore raw

PATCH v2 1/1 cfs-scheduler: Fixed "make check" errors and warnings.

Fixed all make check errors and warnings in cfs_bandwidth01.c and hackbench.c to comply with LTP coding style.

cfs_bandwidth01.c:
- Remove initialization of static variable to 0

Patch v1: https://lore.kernel.org/ltp/[email protected]/

Addressed review comments from patch v1 -> patch v2 hackbench.c:
- Drop SPDX-License-Identifier header addition.
- Remove obsolete header metadata.
- Keep short description and add trailing period.
- Remove initialization of static variables to 0.
- Convert zero-length array to C99 flexible array.
- Drop variadic barf() change.
- Drop __func__-based error messages.
- Separate assignments from if conditions.
- Fix pointer declaration spacing.
- Add blank line after declarations.
- Fix spacing in macro and struct initialization.
- Remove unnecessary braces for single statement.
- Use Authors block for contributor attribution.

---
 .../sched/cfs-scheduler/cfs_bandwidth01.c     |  2 +-
 .../kernel/sched/cfs-scheduler/hackbench.c    | 71 ++++++-------------
 2 files changed, 24 insertions(+), 49 deletions(-)
testcases/kernel/sched/cfs-scheduler/cfs_bandwidth01.c +1 -1
index e52858f8e..8c511f060 100644
@@ -35,7 +35,7 @@
 
 static struct tst_cg_group *cg_level2, *cg_level3a, *cg_level3b;
 static struct tst_cg_group *cg_workers[3];
-static int may_have_waiters = 0;
+static int may_have_waiters;
 
 static void set_cpu_quota(const struct tst_cg_group *const cg,
 			  const float quota_percent)
testcases/kernel/sched/cfs-scheduler/hackbench.c +23 -48

138 lines not on this page · raw message

Signature · 5 lines
2.53.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw
Quoted 182 lines · Samir

Fixed all make check errors and warnings in cfs_bandwidth01.c and hackbench.c to comply with LTP coding style.

cfs_bandwidth01.c:
- Remove initialization of static variable to 0

Patch v1: https://lore.kernel.org/ltp/[email protected]/

Addressed review comments from patch v1 -> patch v2 hackbench.c:
- Drop SPDX-License-Identifier header addition.
- Remove obsolete header metadata.
- Keep short description and add trailing period.
- Remove initialization of static variables to 0.
- Convert zero-length array to C99 flexible array.
- Drop variadic barf() change.
- Drop __func__-based error messages.
- Separate assignments from if conditions.
- Fix pointer declaration spacing.
- Add blank line after declarations.
- Fix spacing in macro and struct initialization.
- Remove unnecessary braces for single statement.
- Use Authors block for contributor attribution.

---
  .../sched/cfs-scheduler/cfs_bandwidth01.c     |  2 +-
  .../kernel/sched/cfs-scheduler/hackbench.c    | 71 ++++++-------------
  2 files changed, 24 insertions(+), 49 deletions(-)
testcases/kernel/sched/cfs-scheduler/cfs_bandwidth01.c +1 -1
index e52858f8e..8c511f060 100644
@@ -35,7 +35,7 @@
 
  static struct tst_cg_group *cg_level2, *cg_level3a, *cg_level3b;
  static struct tst_cg_group *cg_workers[3];
-static int may_have_waiters = 0;
+static int may_have_waiters;
 
  static void set_cpu_quota(const struct tst_cg_group *const cg,
  			  const float quota_percent)
testcases/kernel/sched/cfs-scheduler/hackbench.c +22 -46
index 6f37060aa..846985e3b 100644
@@ -1,49 +1,20 @@
  /******************************************************************************/
-/* 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    */
+/* Authors: Rusty Russell <[email protected]>                             */
+/*          Pierre Peiffer <[email protected]>                          */
+/*          Ingo Molnar <[email protected]>                                       */
+/*          Arjan van de Ven <[email protected]>                            */
+/*          "Zhang, Yanmin" <[email protected]>                    */
+/*          Nathan Lynch <[email protected]>                                      */
+/*          Subrata Modak <[email protected]>                        */
  /*                                                                            */
  /******************************************************************************/
 
  /******************************************************************************/
  /*                                                                            */
-/* 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 <[email protected]>,                        */
-/*              Pierre Peiffer <[email protected]>,                     */
-/*              Ingo Molnar <[email protected]>,                                  */
-/*              Arjan van de Ven <[email protected]>,                       */
-/*              "Zhang, Yanmin" <[email protected]>,               */
-/*              Nathan Lynch <[email protected]>                                  */
-/*                                                                            */
-/* History:     Included into LTP                                             */
-/*                  - June 26 2008 - Subrata Modak<[email protected]>*/
+/*              processes spraying to 20 receivers.                           */
  /*                                                                            */
  /******************************************************************************/
  #include <pthread.h>
@@ -59,24 +30,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 {
@@ -115,7 +86,7 @@ static void fdpair(int fds[2])
  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)
@@ -210,7 +181,8 @@ 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);
@@ -235,11 +207,12 @@ 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
@@ -305,8 +278,11 @@ 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);

testcases/kernel/sched/cfs-scheduler/hackbench.c int main(int argc, char *argv[]) · line 346

Quoted 10 lines
testcases/kernel/sched/cfs-scheduler/hackbench.c +1 -2
@@ -363,9 +339,8 @@ int main(int argc, char *argv[])
 
  	/* free the memory */
  	for (i = 0; i < num_groups; i++) {
-		for (j = 0; j < 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);

Hi,

I wanted to gently follow up on this patch submission. If you have any feedback or concerns, I'm happy to address them and submit a revised version.

Thank you for your time and consideration.

Best regards,
Samir ([email protected])

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
In reply to Samir

Hi Samir,

the AI agent didn't reply to your email at that time, but the output is the following and I agree with that:

Quoted 6 lines

Patch v1: https://lore.kernel.org/ltp/[email protected]/

Addressed review comments from patch v1 -> patch v2 hackbench.c:
- Drop SPDX-License-Identifier header addition.
...

Version changelog (v1->v2 notes, bullet lists, Patch vN links) must be stripped before the final commit is applied. Move them to the cover letter or drop them entirely.

[...]

testcases/kernel/sched/cfs-scheduler/hackbench.c line 12

Quoted 4 lines
testcases/kernel/sched/cfs-scheduler/hackbench.c +0 -4
-/* 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.                                        */

The GPL license prose was removed but no SPDX header was added. Add // SPDX-License-Identifier: GPL-2.0-or-later as the first line to replace the boilerplate; do not leave the file without a license.

[...]

The cfs_bandwidth01.c and hackbench.c changes address different scopes (one line vs. 13 style items). Consider splitting into two commits.

Regards,
LTP AI Reviewer

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp