public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: John Kacur <jkacur@redhat.com>
To: Kurt Kanzenbach <kurt@linutronix.de>
Cc: Clark Williams <williams@redhat.com>,
	rt-users <linux-rt-users@vger.kernel.org>
Subject: Re: [PATCH 1/6] rt-tests: deadline: Remove duplicated code for sched_{set,get}_attr
Date: Wed, 19 Jun 2019 17:46:01 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.21.1906191744060.12022@planxty> (raw)
In-Reply-To: <20190618103841.27249-2-kurt@linutronix.de>



On Tue, 18 Jun 2019, Kurt Kanzenbach wrote:

> The system calls for sched_get_attr() and sched_set_attr() are already
> implemented. Get rid of the code and use the existing libary.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>  src/sched_deadline/cyclicdeadline.c | 36 +------------------
>  src/sched_deadline/deadline_test.c  | 72 ++-----------------------------------
>  2 files changed, 3 insertions(+), 105 deletions(-)
> 
> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
> index 47892daf747b..754670c4e7d4 100644
> --- a/src/sched_deadline/cyclicdeadline.c
> +++ b/src/sched_deadline/cyclicdeadline.c
> @@ -22,31 +22,17 @@
>  #include <linux/magic.h>
>  
>  #include <rt-utils.h>
> +#include <rt-sched.h>
>  
>  #ifdef __i386__
> -#ifndef __NR_sched_setattr
> -#define __NR_sched_setattr		351
> -#endif
> -#ifndef __NR_sched_getattr
> -#define __NR_sched_getattr		352
> -#endif
>  #ifndef __NR_getcpu
>  #define __NR_getcpu			309
>  #endif
>  #else /* x86_64 */
> -#ifndef __NR_sched_setattr
> -#define __NR_sched_setattr		314
> -#endif
> -#ifndef __NR_sched_getattr
> -#define __NR_sched_getattr		315
> -#endif
>  #ifndef __NR_getcpu
>  #define __NR_getcpu			309
>  #endif
>  #endif /* i386 or x86_64 */
> -#ifndef SCHED_DEADLINE
> -#define SCHED_DEADLINE		6
> -#endif
>  
>  #define _STR(x) #x
>  #define STR(x) _STR(x)
> @@ -58,8 +44,6 @@
>  #define CPUSET_LOCAL	"my_cpuset"
>  
>  #define gettid() syscall(__NR_gettid)
> -#define sched_setattr(pid, attr, flags) syscall(__NR_sched_setattr, pid, attr, flags)
> -#define sched_getattr(pid, attr, size, flags) syscall(__NR_sched_getattr, pid, attr, size, flags)
>  #define getcpu(cpup, nodep, unused) syscall(__NR_getcpu, cpup, nodep, unused)
>  
>  typedef unsigned long long u64;
> @@ -115,24 +99,6 @@ struct sched_data {
>  	char buff[BUFSIZ+1];
>  };
>  
> -struct sched_attr {
> -	u32 size;
> -
> -	u32 sched_policy;
> -	u64 sched_flags;
> -
> -	/* SCHED_NORMAL, SCHED_BATCH */
> -	s32 sched_nice;
> -
> -	/* SCHED_FIFO, SCHED_RR */
> -	u32 sched_priority;
> -
> -	/* SCHED_DEADLINE */
> -	u64 sched_runtime;
> -	u64 sched_deadline;
> -	u64 sched_period;
> -};
> -
>  static int shutdown;
>  
>  static pthread_barrier_t barrier;
> diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
> index b01e3f27e00f..c3b9dceb5209 100644
> --- a/src/sched_deadline/deadline_test.c
> +++ b/src/sched_deadline/deadline_test.c
> @@ -51,6 +51,8 @@
>  #include <linux/unistd.h>
>  #include <linux/magic.h>
>  
> +#include <rt-sched.h>
> +
>  /**
>   * usage - show the usage of the program and exit.
>   * @argv: The program passed in args
> @@ -82,43 +84,6 @@ static void usage(char **argv)
>  	exit(-1);
>  }
>  
> -/*
> - * sched_setattr() and sched_getattr() are new system calls. We need to
> - * hardcode it here.
> - */
> -#if defined(__i386__)
> -
> -#ifndef __NR_sched_setattr
> -#define __NR_sched_setattr		351
> -#endif
> -#ifndef __NR_sched_getattr
> -#define __NR_sched_getattr		352
> -#endif
> -
> -#elif defined(__x86_64__)
> -
> -#ifndef __NR_sched_setattr
> -#define __NR_sched_setattr		314
> -#endif
> -#ifndef __NR_sched_getattr
> -#define __NR_sched_getattr		315
> -#endif
> -
> -#endif /* i386 or x86_64 */
> -
> -#if !defined(__NR_sched_setattr)
> -# error "Your arch does not support sched_setattr()"
> -#endif
> -
> -#if !defined(__NR_sched_getattr)
> -# error "Your arch does not support sched_getattr()"
> -#endif
> -
> -/* If not included in the headers, define sched deadline policy numbe */
> -#ifndef SCHED_DEADLINE
> -#define SCHED_DEADLINE		6
> -#endif
> -
>  #define _STR(x) #x
>  #define STR(x) _STR(x)
>  
> @@ -140,45 +105,12 @@ static void usage(char **argv)
>  
>  /* Define the system call interfaces */
>  #define gettid() syscall(__NR_gettid)
> -#define sched_setattr(pid, attr, flags) syscall(__NR_sched_setattr, pid, attr, flags)
> -#define sched_getattr(pid, attr, size, flags) syscall(__NR_sched_getattr, pid, attr, size, flags)
>  
>  typedef unsigned long long u64;
>  typedef unsigned int u32;
>  typedef int s32;
>  
>  /**
> - * struct sched_attr - get/set attr system call descriptor.
> - *
> - * This is the descriptor defined for setting SCHED_DEADLINE tasks.
> - * It will someday be in a header file.
> - *
> - * The fields specific for deadline:
> - *
> - *  @sched_policy: 6 is for deadline
> - *  @sched_runtime: The runtime in nanoseconds
> - *  @sched_deadline: The deadline in nanoseconds.
> - *  @sched_period: The period, if different than deadline (not used here)
> - */
> -struct sched_attr {
> -	u32 size;
> -
> -	u32 sched_policy;
> -	u64 sched_flags;
> -
> -	/* SCHED_NORMAL, SCHED_BATCH */
> -	s32 sched_nice;
> -
> -	/* SCHED_FIFO, SCHED_RR */
> -	u32 sched_priority;
> -
> -	/* SCHED_DEADLINE */
> -	u64 sched_runtime;
> -	u64 sched_deadline;
> -	u64 sched_period;
> -};
> -
> -/**
>   * struct sched_data - the descriptor for the threads.
>   *
>   * This is the descriptor that will be passed as the thread data.
> -- 
> 2.11.0
> 

Signed-off-by: John Kacur <jkacur@redhat.com>

  reply	other threads:[~2019-06-19 15:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18 10:38 [PATCH 0/6] rt-tests: deadline: Cleanups Kurt Kanzenbach
2019-06-18 10:38 ` [PATCH 1/6] rt-tests: deadline: Remove duplicated code for sched_{set,get}_attr Kurt Kanzenbach
2019-06-19 15:46   ` John Kacur [this message]
2019-06-18 10:38 ` [PATCH 2/6] rt-tests: cyclicdeadline: Remove unused getcpu code Kurt Kanzenbach
2019-06-19 15:46   ` John Kacur
2019-06-18 10:38 ` [PATCH 3/6] rt-tests: deadline: Remove duplicated gettid() code Kurt Kanzenbach
2019-06-19 15:48   ` John Kacur
2019-06-24 13:40     ` Sebastian Andrzej Siewior
2019-06-25  9:29       ` John Kacur
2019-06-25 13:52         ` Sebastian Andrzej Siewior
2019-06-18 10:38 ` [PATCH 4/6] rt-tests: cyclicdeadline: Add options to usage Kurt Kanzenbach
2019-06-19 15:48   ` John Kacur
2019-06-18 10:38 ` [PATCH 5/6] rt-tests: cyclicdeadline: Print fail only if something failed Kurt Kanzenbach
2019-06-19 15:49   ` John Kacur
2019-06-18 10:38 ` [PATCH 6/6] rt-tests: cyclicdeadline: Fix cgroup setup Kurt Kanzenbach
2019-06-19 15:49   ` John Kacur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.21.1906191744060.12022@planxty \
    --to=jkacur@redhat.com \
    --cc=kurt@linutronix.de \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox