All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, lars@metafoo.de, clemens@ladisch.de,
	Takashi Sakamoto <o-takashi@sakamocchi.jp>
Subject: Re: [PATCH RFC 16/21] ALSA: pcm/oss: refer to parameters instead of copying to reduce usage of kernel stack
Date: Mon, 15 May 2017 11:15:49 +0200	[thread overview]
Message-ID: <s5hpofabhve.wl-tiwai@suse.de> (raw)
In-Reply-To: <s5hr2zqbi4p.wl-tiwai@suse.de>

On Mon, 15 May 2017 11:10:14 +0200,
Takashi Iwai wrote:
> 
> On Sun, 14 May 2017 10:57:51 +0200,
> Takashi Sakamoto wrote:
> > 
> > Some functions in compatibility layer for Open Sound System interface has
> > local variable to copy some parameters in runtime of PCM substream, while
> > this can be replaced with reference of pointers to parameter itself. This
> > brings an advantage to reduce usage of kernel stack.
> > 
> > This commit applies this idea.
> 
> Are you sure that this patch won't break anything?
> Using the local copy is for not changing the values at evaluation
> before actually trying to set.

Never mind, I understand that it's about format_mask and it's
consitfied.


Takashi

> 
> 
> thanks,
> 
> Takashi
> 
> > 
> > Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> > ---
> >  sound/core/oss/pcm_oss.c    | 16 ++++++++--------
> >  sound/core/oss/pcm_plugin.c |  5 +++--
> >  sound/core/oss/pcm_plugin.h |  2 +-
> >  3 files changed, 12 insertions(+), 11 deletions(-)
> > 
> > diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
> > index 2a47351..e306f05 100644
> > --- a/sound/core/oss/pcm_oss.c
> > +++ b/sound/core/oss/pcm_oss.c
> > @@ -848,7 +848,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream,
> >  	int direct;
> >  	snd_pcm_format_t format, sformat;
> >  	int n;
> > -	struct snd_mask sformat_mask;
> > +	const struct snd_mask *sformat_mask;
> >  	struct snd_mask mask;
> >  
> >  	if (trylock) {
> > @@ -891,18 +891,18 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream,
> >  
> >  	format = snd_pcm_oss_format_from(runtime->oss.format);
> >  
> > -	sformat_mask = *hw_param_mask(sparams, SNDRV_PCM_HW_PARAM_FORMAT);
> > +	sformat_mask = hw_param_mask_c(sparams, SNDRV_PCM_HW_PARAM_FORMAT);
> >  	if (direct)
> >  		sformat = format;
> >  	else
> > -		sformat = snd_pcm_plug_slave_format(format, &sformat_mask);
> > +		sformat = snd_pcm_plug_slave_format(format, sformat_mask);
> >  
> >  	if ((__force int)sformat < 0 ||
> > -	    !snd_mask_test(&sformat_mask, (__force int)sformat)) {
> > +	    !snd_mask_test(sformat_mask, (__force int)sformat)) {
> >  		for (sformat = (__force snd_pcm_format_t)0;
> >  		     (__force int)sformat <= (__force int)SNDRV_PCM_FORMAT_LAST;
> >  		     sformat = (__force snd_pcm_format_t)((__force int)sformat + 1)) {
> > -			if (snd_mask_test(&sformat_mask, (__force int)sformat) &&
> > +			if (snd_mask_test(sformat_mask, (__force int)sformat) &&
> >  			    snd_pcm_oss_format_to(sformat) >= 0)
> >  				break;
> >  		}
> > @@ -1780,7 +1780,7 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
> >  	int direct;
> >  	struct snd_pcm_hw_params *params;
> >  	unsigned int formats = 0;
> > -	struct snd_mask format_mask;
> > +	const struct snd_mask *format_mask;
> >  	int fmt;
> >  
> >  	if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0)
> > @@ -1802,12 +1802,12 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
> >  		return -ENOMEM;
> >  	_snd_pcm_hw_params_any(params);
> >  	err = snd_pcm_hw_refine(substream, params);
> > -	format_mask = *hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 
> > +	format_mask = hw_param_mask_c(params, SNDRV_PCM_HW_PARAM_FORMAT);
> >  	kfree(params);
> >  	if (err < 0)
> >  		return err;
> >  	for (fmt = 0; fmt < 32; ++fmt) {
> > -		if (snd_mask_test(&format_mask, fmt)) {
> > +		if (snd_mask_test(format_mask, fmt)) {
> >  			int f = snd_pcm_oss_format_to(fmt);
> >  			if (f >= 0)
> >  				formats |= f;
> > diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
> > index 727ac44..cadc937 100644
> > --- a/sound/core/oss/pcm_plugin.c
> > +++ b/sound/core/oss/pcm_plugin.c
> > @@ -266,7 +266,8 @@ snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pc
> >  	return frames;
> >  }
> >  
> > -static int snd_pcm_plug_formats(struct snd_mask *mask, snd_pcm_format_t format)
> > +static int snd_pcm_plug_formats(const struct snd_mask *mask,
> > +				snd_pcm_format_t format)
> >  {
> >  	struct snd_mask formats = *mask;
> >  	u64 linfmts = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S8 |
> > @@ -309,7 +310,7 @@ static snd_pcm_format_t preferred_formats[] = {
> >  };
> >  
> >  snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format,
> > -					   struct snd_mask *format_mask)
> > +					   const struct snd_mask *format_mask)
> >  {
> >  	int i;
> >  
> > diff --git a/sound/core/oss/pcm_plugin.h b/sound/core/oss/pcm_plugin.h
> > index a5035c2..38e2c14 100644
> > --- a/sound/core/oss/pcm_plugin.h
> > +++ b/sound/core/oss/pcm_plugin.h
> > @@ -126,7 +126,7 @@ int snd_pcm_plug_format_plugins(struct snd_pcm_substream *substream,
> >  				struct snd_pcm_hw_params *slave_params);
> >  
> >  snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format,
> > -					   struct snd_mask *format_mask);
> > +					   const struct snd_mask *format_mask);
> >  
> >  int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin);
> >  
> > -- 
> > 2.9.3
> > 

  reply	other threads:[~2017-05-15  9:15 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-14  8:57 [PATCH RFC 00/21] ALSA: pcm: add tracepoints for PCM params operation Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 01/21] ALSA: pcm: add a helper function to constrain mask-type parameters Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 02/21] ALSA: pcm: add a helper function to constrain interval-type parameters Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 03/21] ALSA: pcm: add a helper function to apply parameter rules Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 04/21] ALSA: pcm: tracepoints for refining PCM parameters Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 05/21] ALSA: pcm: enable parameter tracepoints at CONFIG_SND_DEBUG only Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 06/21] ALSA: pcm: use goto statement instead of while statement to reduce indentation Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 07/21] ALSA: pcm: remove function local variable with alternative evaluation Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 08/21] ALSA: pcm: adaption of code formatting Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 09/21] ALSA: pcm: add comment about application of rule to PCM parameters Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 10/21] ALSA: pcm: constify function local and read-only table Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 11/21] ALSA: pcm: localize snd_pcm_hw_params_choose() Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 12/21] ALSA: pcm: add tracepoints for selection process of hardware parameters at SNDRV_PCM_IOCTL_HW_PARAMS Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 13/21] ALSA: pcm: use helper functions to check whether parameters are determined Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 14/21] ALSA: pcm: use helper function to refer parameter as read-only Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 15/21] ALSA: pcm: add const qualifier for read-only table for sampling rate Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 16/21] ALSA: pcm/oss: refer to parameters instead of copying to reduce usage of kernel stack Takashi Sakamoto
2017-05-15  9:10   ` Takashi Iwai
2017-05-15  9:15     ` Takashi Iwai [this message]
2017-05-14  8:57 ` [PATCH RFC 17/21] ALSA: pcm: check type of parameter in added rule Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 18/21] ALSA: pcm: calculate non-mask/non-interval parameters always when possible Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 19/21] ALSA: pcm: move fixup of info flag after selecting single parameters Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 20/21] ALSA: pcm: return error immediately for parameters refinement Takashi Sakamoto
2017-05-14  8:57 ` [PATCH RFC 21/21] ALSA: pcm: return error immediately at refine ioctl Takashi Sakamoto
2017-05-15  8:42 ` [PATCH RFC 00/21] ALSA: pcm: add tracepoints for PCM params operation Takashi Iwai
2017-05-15 14:29   ` Takashi Sakamoto
2017-05-15 14:34     ` Takashi Iwai
2017-05-16 11:54       ` Takashi Sakamoto

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=s5hpofabhve.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=lars@metafoo.de \
    --cc=o-takashi@sakamocchi.jp \
    /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.