All of lore.kernel.org
 help / color / mirror / Atom feed
From: "florian.bezdeka@siemens.com" <florian.bezdeka@siemens.com>
To: "xenomai@xenomai.org" <xenomai@xenomai.org>,
	"jan.kiszka@siemens.com" <jan.kiszka@siemens.com>,
	"chensong@tj.kylinos.cn" <chensong@tj.kylinos.cn>
Subject: Re: [PATCH 3/3] lib/cobalt: Introduce generic feature initialization and check API
Date: Fri, 13 Nov 2020 16:10:37 +0000	[thread overview]
Message-ID: <5ed4631ca57f9b9ea2d92ec9892ceb8ace1431ab.camel@siemens.com> (raw)
In-Reply-To: <06f7264a-a5a2-b10b-4584-4e3a89104855@siemens.com>

On Fri, 2020-11-13 at 14:25 +0100, Jan Kiszka wrote:
> On 13.11.20 13:00, florian.bezdeka--- via Xenomai wrote:
> > From: Florian Bezdeka <florian.bezdeka@siemens.com>
> > 
> > The feature initialization was arch specific up to now and the
> > available features (= features offered by the currently running
> > kernel)
> > were no longer accessible once the bind syscall finished.
> > 
> > This patch introduces a simple API for fetching the offered
> > features
> > during runtime.
> > 
> > Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> > ---
> >  lib/cobalt/init.c     |  2 +-
> >  lib/cobalt/internal.c | 10 ++++++++++
> >  lib/cobalt/internal.h | 39 +++++++++++++++++++++++++++++++++++----
> >  3 files changed, 46 insertions(+), 5 deletions(-)
> > 
> > diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c
> > index 6907ace36..20e28ccb0 100644
> > --- a/lib/cobalt/init.c
> > +++ b/lib/cobalt/init.c
> > @@ -177,7 +177,7 @@ static void low_init(void)
> >  		early_panic("mlockall: %s", strerror(errno));
> >  
> >  	trace_me("memory locked");
> > -	cobalt_arch_check_features(f);
> > +	cobalt_features_init(f);
> >  	cobalt_init_umm(f->vdso_offset);
> >  	trace_me("memory heaps mapped");
> >  	cobalt_init_current_keys();
> > diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c
> > index 43330060a..303d86f99 100644
> > --- a/lib/cobalt/internal.c
> > +++ b/lib/cobalt/internal.c
> > @@ -565,3 +565,13 @@ void cobalt_assert_nrt(void)
> >  	if (cobalt_should_warn())
> >  		pthread_kill(pthread_self(), SIGDEBUG);
> >  }
> > +
> > +unsigned int cobalt_features;
> > +
> > +void cobalt_features_init(struct cobalt_featinfo *f)
> > +{
> > +	cobalt_features = f->feat_all;
> > +
> > +	/* Trigger arch specific feature initialization */
> > +	cobalt_arch_check_features(f);
> > +}
> > \ No newline at end of file
> > diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
> > index 4ca99d927..ac7ce24f3 100644
> > --- a/lib/cobalt/internal.h
> > +++ b/lib/cobalt/internal.h
> > @@ -86,10 +86,6 @@ int cobalt_xlate_schedparam(int policy,
> >  			    struct sched_param *param);
> >  int cobalt_init(void);
> >  
> > -struct cobalt_featinfo;
> > -
> > -void cobalt_arch_check_features(struct cobalt_featinfo *finfo);
> > -
> >  extern struct sigaction __cobalt_orig_sigdebug;
> >  
> >  extern int __cobalt_std_fifo_minpri,
> > @@ -98,4 +94,39 @@ extern int __cobalt_std_fifo_minpri,
> >  extern int __cobalt_std_rr_minpri,
> >  	   __cobalt_std_rr_maxpri;
> >  
> > +extern unsigned int cobalt_features;
> > +
> > +struct cobalt_featinfo;
> > +
> > +/**
> > + * Arch specific feature initialization
> > + *
> > + * @param finfo
> > + */
> > +void cobalt_arch_check_features(struct cobalt_featinfo *finfo);
> > +
> > +/**
> > + * Initialize the feature handling.
> > + *
> > + * @param f Feature info that will be cached for future feature
> > checks
> > + */
> > +void cobalt_features_init(struct cobalt_featinfo *f)
> > +	__attribute__((visibility("hidden")));
> 
> What will "hidden" do here?

I will remove it. It was added by accident.
It would prevent the function from being added to the linking
interface. As a result it would not be possible to use this function
from outside the library. 

Reducing the exported symbols is a follow up topic if relevant at all.

> 
> > +
> > +/**
> > + * Check if a given set of features is available / provided by the
> > kernel
> > + *
> > + * @param feat_mask A bit mask of features to check availability
> > for. See
> > + * __xn_feat_* macros for a list of defined features
> > + *
> > + * @return 1 if all features are available, 0 otherwise
> > + */
> > +inline int cobalt_features_available(unsigned int feat_mask)
> 
> Why not "static"?
> 
> And "bool" would be a better return type.

Right. The first implementation was bool, but bool seems to be rarely
used in the codebase. Will take that into v2 as well as the missing
"static".

> 
> > +{
> > +	if ((cobalt_features & feat_mask) == feat_mask)
> > +		return 1;
> > +
> > +	return 0;
> 
> return ((cobalt_features & feat_mask) == feat_mask);
> 
> > +}
> > +
> >  #endif /* _LIB_COBALT_INTERNAL_H */
> > 
> 
> Jan

  reply	other threads:[~2020-11-13 16:10 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03  3:05 [PATCH 5/5] lib/cobalt/clock.c:dispatch clock_settime chensong
2020-11-10 10:24 ` Jan Kiszka
2020-11-11  3:55   ` chensong
2020-11-11  7:29     ` Jan Kiszka
2020-11-11  9:23       ` chensong
2020-11-11  9:43         ` Jan Kiszka
2020-11-11 10:13           ` chensong
2020-11-13 11:47             ` Florian Bezdeka
2020-11-13 11:56               ` Jan Kiszka
2020-11-13 11:59                 ` [PATCH 0/3] Make offered kernel features accessible during florian.bezdeka
2020-11-13 12:00                   ` [PATCH 1/3] cobalt uapi: Introducing new feature flag for settime64 availability florian.bezdeka
2020-11-13 13:25                     ` Jan Kiszka
2020-11-13 16:18                       ` florian.bezdeka
2020-11-14  7:33                         ` Jan Kiszka
2020-11-14  6:57                     ` song
2020-11-14  7:32                       ` Jan Kiszka
2020-11-14  7:50                         ` song
2020-11-16 14:07                           ` [PATCH v2 0/3] Make offered kernel features accessible during florian.bezdeka
2020-11-16 14:07                             ` [PATCH v2 1/3] lib/cobalt: Rename cobalt_check_features to cobalt_arch_check_features florian.bezdeka
2020-11-16 14:07                             ` [PATCH v2 3/3] cobalt uapi: Introducing new feature flag for time64 availability florian.bezdeka
2020-12-11  6:41                               ` Jan Kiszka
2020-11-16 14:07                             ` [PATCH v2 2/3] lib/cobalt: Introduce generic feature initialization and check API florian.bezdeka
2020-11-17  4:31                               ` song
2020-11-17  8:29                                 ` florian.bezdeka
2020-11-17  8:43                                   ` song
2020-11-17 14:28                               ` Jan Kiszka
2020-11-13 12:00                   ` [PATCH 2/3] lib/cobalt: Rename cobalt_check_features to cobalt_arch_check_features florian.bezdeka
2020-11-13 12:00                   ` [PATCH 3/3] lib/cobalt: Introduce generic feature initialization and check API florian.bezdeka
2020-11-13 13:25                     ` Jan Kiszka
2020-11-13 16:10                       ` florian.bezdeka [this message]
2020-11-14  7:04               ` [PATCH 5/5] lib/cobalt/clock.c:dispatch clock_settime song

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=5ed4631ca57f9b9ea2d92ec9892ceb8ace1431ab.camel@siemens.com \
    --to=florian.bezdeka@siemens.com \
    --cc=chensong@tj.kylinos.cn \
    --cc=jan.kiszka@siemens.com \
    --cc=xenomai@xenomai.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.