All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Li Zefan <lizf@cn.fujitsu.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Aditya Kali <adityakali@google.com>,
	Oleg Nesterov <oleg@redhat.com>,
	Kay Sievers <kay.sievers@vrfy.org>,
	Tim Hockin <thockin@hockin.org>, Tejun Heo <htejun@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/8] cgroups: add res_counter_write_u64() API
Date: Wed, 25 Jan 2012 19:31:03 +0100	[thread overview]
Message-ID: <20120125183100.GD20878@somewhere> (raw)
In-Reply-To: <20120116122713.GA25863@shutemov.name>

On Mon, Jan 16, 2012 at 02:27:13PM +0200, Kirill A. Shutemov wrote:
> On Fri, Jan 13, 2012 at 07:13:47PM +0100, Frederic Weisbecker wrote:
> > Extend the resource counter API with a mirror of res_counter_read_u64() to
> > make it handy to update a resource counter value from a cgroup subsystem
> > u64 value file.
> 
> I still think it worth to have two versions of res_counter_write_u64().
> From my POV, it's clean enough, but consistent with res_counter_read_u64()
> and faster on 64bit system.
> 
> What do you think?

Yeah right let's do this. Can I get your signed-off-by to take the below?

Thanks.

> 
> ---
> diff --git a/include/linux/res_counter.h b/include/linux/res_counter.h
> index c9d625c..1b3fe05 100644
> --- a/include/linux/res_counter.h
> +++ b/include/linux/res_counter.h
> @@ -82,6 +82,8 @@ int res_counter_memparse_write_strategy(const char *buf,
>  int res_counter_write(struct res_counter *counter, int member,
>  		      const char *buffer, write_strategy_fn write_strategy);
>  
> +void res_counter_write_u64(struct res_counter *counter, int member, u64 val);
> +
>  /*
>   * the field descriptors. one for each member of res_counter
>   */
> diff --git a/kernel/res_counter.c b/kernel/res_counter.c
> index 6d269cc..aad4ddb 100644
> --- a/kernel/res_counter.c
> +++ b/kernel/res_counter.c
> @@ -167,12 +167,27 @@ int res_counter_memparse_write_strategy(const char *buf,
>  	return 0;
>  }
>  
> +#if BITS_PER_LONG == 32
> +void res_counter_write_u64(struct res_counter *counter, int member, u64 val)
> +{
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&counter->lock, flags);
> +	*res_counter_member(counter, member) = val;
> +	spin_unlock_irqrestore(&counter->lock, flags);
> +}
> +#else
> +void res_counter_write_u64(struct res_counter *counter, int member, u64 val)
> +{
> +	*res_counter_member(counter, member) = val;
> +}
> +#endif
> +
>  int res_counter_write(struct res_counter *counter, int member,
>  		      const char *buf, write_strategy_fn write_strategy)
>  {
>  	char *end;
> -	unsigned long flags;
> -	unsigned long long tmp, *val;
> +	unsigned long long tmp;
>  
>  	if (write_strategy) {
>  		if (write_strategy(buf, &tmp))
> @@ -182,9 +197,8 @@ int res_counter_write(struct res_counter *counter, int member,
>  		if (*end != '\0')
>  			return -EINVAL;
>  	}
> -	spin_lock_irqsave(&counter->lock, flags);
> -	val = res_counter_member(counter, member);
> -	*val = tmp;
> -	spin_unlock_irqrestore(&counter->lock, flags);
> +
> +	res_counter_write_u64(counter, member, tmp);
> +
>  	return 0;
>  }
> -- 
>  Kirill A. Shutemov

  reply	other threads:[~2012-01-25 18:31 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-13 18:13 [PATCH 0/8] cgroups: Task counter subsystem v7 Frederic Weisbecker
2012-01-13 18:13 ` Frederic Weisbecker
     [not found] ` <1326478441-3048-1-git-send-email-fweisbec-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-13 18:13   ` Frederic Weisbecker
2012-01-13 18:13     ` Frederic Weisbecker
2012-01-13 18:13   ` [PATCH 1/8] cgroups: add res_counter_write_u64() API Frederic Weisbecker
2012-01-13 18:13     ` Frederic Weisbecker
2012-01-13 18:13   ` [PATCH 7/8] cgroups: allow subsystems to cancel a fork Frederic Weisbecker
2012-01-13 18:13     ` Frederic Weisbecker
2012-01-13 18:14   ` [PATCH 8/8] cgroups: Add a task counter subsystem Frederic Weisbecker
2012-01-13 18:14     ` Frederic Weisbecker
     [not found]     ` <1326478441-3048-17-git-send-email-fweisbec-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-01-16 12:38       ` Kirill A. Shutemov
2012-01-16 12:38         ` Kirill A. Shutemov
2012-01-13 18:14   ` Frederic Weisbecker
2012-01-13 18:14     ` Frederic Weisbecker
2012-01-13 18:13 ` [PATCH 1/8] cgroups: add res_counter_write_u64() API Frederic Weisbecker
2012-01-16 12:27   ` Kirill A. Shutemov
2012-01-25 18:31     ` Frederic Weisbecker [this message]
2012-01-25 18:35       ` Kirill A. Shutemov
2012-01-13 18:13 ` [PATCH 2/8] cgroups: new resource counter inheritance API Frederic Weisbecker
2012-01-13 18:13 ` Frederic Weisbecker
2012-01-13 18:13 ` [PATCH 3/8] cgroups: ability to stop res charge propagation on bounded ancestor Frederic Weisbecker
2012-01-13 18:13 ` Frederic Weisbecker
2012-01-13 18:13 ` [PATCH 4/8] cgroups: add res counter common ancestor searching Frederic Weisbecker
2012-01-13 18:13 ` Frederic Weisbecker
2012-01-13 18:13 ` [PATCH 5/8] res_counter: allow charge failure pointer to be null Frederic Weisbecker
2012-01-13 18:13 ` Frederic Weisbecker
2012-01-13 18:13 ` [PATCH 6/8] cgroups: pull up res counter charge failure interpretation to caller Frederic Weisbecker
2012-01-13 18:13 ` Frederic Weisbecker
2012-01-13 18:13 ` [PATCH 7/8] cgroups: allow subsystems to cancel a fork Frederic Weisbecker
  -- strict thread matches above, loose matches on Subject: below --
2011-07-29 16:13 [PATCH 0/8 v3] cgroups: Task counter subsystem (was: New max number of tasks subsystem) Frederic Weisbecker
2011-07-29 16:13 ` [PATCH 1/8] cgroups: Add res_counter_write_u64() API Frederic Weisbecker
2011-08-09 15:17   ` Oleg Nesterov
2011-08-09 17:31     ` Frederic Weisbecker

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=20120125183100.GD20878@somewhere \
    --to=fweisbec@gmail.com \
    --cc=adityakali@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=htejun@gmail.com \
    --cc=kay.sievers@vrfy.org \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=oleg@redhat.com \
    --cc=thockin@hockin.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.