OpenVZ Forum


Home » Mailing lists » Devel » [PATCH 1/3] nitpick: make simple functions inline
[PATCH 1/3] nitpick: make simple functions inline [message #44481] Sun, 11 December 2011 14:45 Go to next message
Glauber Costa is currently offline  Glauber Costa
Messages: 916
Registered: October 2011
Senior Member
From: *parallels.com
Those are quite simple bit-testing functions that are
only used within this file. Not reason for them not to
be inline.

Signed-off-by: Glauber Costa <glommer@parallels.com>
---
kernel/cgroup.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index d9d5648..e4b9d3c 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -241,12 +241,12 @@ static int cgroup_is_releasable(const struct cgroup *cgrp)
return (cgrp->flags & bits) == bits;
}

-static int notify_on_release(const struct cgroup *cgrp)
+static inline int notify_on_release(const struct cgroup *cgrp)
{
return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
}

-static int clone_children(const struct cgroup *cgrp)
+static inline int clone_children(const struct cgroup *cgrp)
{
return test_bit(CGRP_CLONE_CHILDREN, &cgrp->flags);
}
--
1.7.6.4
Re: [PATCH 1/3] nitpick: make simple functions inline [message #44490 is a reply to message #44481] Sun, 11 December 2011 20:44 Go to previous messageGo to next message
Glauber Costa is currently offline  Glauber Costa
Messages: 916
Registered: October 2011
Senior Member
From: *149.9.224.misp.ru
On 12/11/2011 07:55 PM, KOSAKI Motohiro wrote:
>> -static int notify_on_release(const struct cgroup *cgrp)
>> +static inline int notify_on_release(const struct cgroup *cgrp)
>> {
>> return test_bit(CGRP_NOTIFY_ON_RELEASE,&cgrp->flags);
>> }
>>
>> -static int clone_children(const struct cgroup *cgrp)
>> +static inline int clone_children(const struct cgroup *cgrp)
>> {
>> return test_bit(CGRP_CLONE_CHILDREN,&cgrp->flags);
>> }
>
> Can you please tell us which compiler failed automatic inlining?
> I suspect gcc is enough sane and we don't need this patch.

Of course we don't need, that's the very definition of a "nitpick".
This patch is directed towards the reader, not the compiler. Maintainers
are free to take it or not, although I believe being explicit is better.
Re: [PATCH 1/3] nitpick: make simple functions inline [message #44520 is a reply to message #44490] Mon, 12 December 2011 17:27 Go to previous messageGo to next message
Tejun Heo is currently offline  Tejun Heo
Messages: 184
Registered: November 2006
Senior Member
From: *parallels.com
Hello,

On Sun, Dec 11, 2011 at 09:44:54PM +0100, Glauber Costa wrote:
> On 12/11/2011 07:55 PM, KOSAKI Motohiro wrote:
> > Can you please tell us which compiler failed automatic inlining?
> > I suspect gcc is enough sane and we don't need this patch.
>
> Of course we don't need, that's the very definition of a "nitpick".
> This patch is directed towards the reader, not the compiler. Maintainers
> are free to take it or not, although I believe being explicit is better.

These days, I don't think adding inline buys us much (other than
explicit cases where always_inline or noinline is necessary). gcc
already does good enough job for inlining and 'inline' hint seems more
to hinder rather than help and I don't really see what it buys for
code readers either, so I won't be taking this one.

Thanks.

--
tejun
Re: [PATCH 1/3] nitpick: make simple functions inline [message #44544 is a reply to message #44481] Wed, 14 December 2011 01:09 Go to previous message
Li Zefan is currently offline  Li Zefan
Messages: 90
Registered: February 2008
Member
From: *parallels.com
22:45, Glauber Costa wrote:
> Those are quite simple bit-testing functions that are
> only used within this file. Not reason for them not to
> be inline.
>

It's better to leave the optimization decision to gcc.

And I've confirmed they are inlined by gcc in my box.

(btw, please add "cgroup" prefix to the patch subject line)

> Signed-off-by: Glauber Costa <glommer@parallels.com>
> ---
> kernel/cgroup.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index d9d5648..e4b9d3c 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -241,12 +241,12 @@ static int cgroup_is_releasable(const struct cgroup *cgrp)
> return (cgrp->flags & bits) == bits;
> }
>
> -static int notify_on_release(const struct cgroup *cgrp)
> +static inline int notify_on_release(const struct cgroup *cgrp)
> {
> return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
> }
>
> -static int clone_children(const struct cgroup *cgrp)
> +static inline int clone_children(const struct cgroup *cgrp)
> {
> return test_bit(CGRP_CLONE_CHILDREN, &cgrp->flags);
> }
Re: [PATCH 1/3] nitpick: make simple functions inline [message #44614 is a reply to message #44481] Sun, 11 December 2011 18:55 Go to previous message
KOSAKI Motohiro is currently offline  KOSAKI Motohiro
Messages: 26
Registered: May 2008
Junior Member
From: *parallels.com
> -static int notify_on_release(const struct cgroup *cgrp)
> +static inline int notify_on_release(const struct cgroup *cgrp)
> {
> return test_bit(CGRP_NOTIFY_ON_RELEASE,&cgrp->flags);
> }
>
> -static int clone_children(const struct cgroup *cgrp)
> +static inline int clone_children(const struct cgroup *cgrp)
> {
> return test_bit(CGRP_CLONE_CHILDREN,&cgrp->flags);
> }

Can you please tell us which compiler failed automatic inlining?
I suspect gcc is enough sane and we don't need this patch.
Previous Topic: Re: [GIT PULL 0/3] perf/core fixes and improvements
Next Topic: [PATCH 0/3] Simple cleanups for cgroups
Goto Forum:
  


Current Time: Fri Jun 22 12:55:27 GMT 2018