[PATCH] cgroup: use read lock to guard find_existing_css_set() - Kernel

This is a discussion on [PATCH] cgroup: use read lock to guard find_existing_css_set() - Kernel ; The function does not modify anything (except the temporary css template), so it's sufficient to hold read lock. Signed-off-by: Li Zefan --- kernel/cgroup.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 2727f92..e9eb5da 100644 ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: [PATCH] cgroup: use read lock to guard find_existing_css_set()

  1. [PATCH] cgroup: use read lock to guard find_existing_css_set()

    The function does not modify anything (except the temporary
    css template), so it's sufficient to hold read lock.

    Signed-off-by: Li Zefan
    ---
    kernel/cgroup.c | 4 ++--
    1 files changed, 2 insertions(+), 2 deletions(-)

    diff --git a/kernel/cgroup.c b/kernel/cgroup.c
    index 2727f92..e9eb5da 100644
    --- a/kernel/cgroup.c
    +++ b/kernel/cgroup.c
    @@ -406,11 +406,11 @@ static struct css_set *find_css_set(

    /* First see if we already have a cgroup group that matches
    * the desired set */
    - write_lock(&css_set_lock);
    + read_lock(&css_set_lock);
    res = find_existing_css_set(oldcg, cgrp, template);
    if (res)
    get_css_set(res);
    - write_unlock(&css_set_lock);
    + read_unlock(&css_set_lock);

    if (res)
    return res;
    -- 1.5.4.rc3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. Re: [PATCH] cgroup: use read lock to guard find_existing_css_set()

    On Tue, Apr 22, 2008 at 8:04 PM, Li Zefan wrote:
    > The function does not modify anything (except the temporary
    > css template), so it's sufficient to hold read lock.
    >
    > Signed-off-by: Li Zefan


    Acked-by: Paul Menage

    Thanks.

    > ---
    > kernel/cgroup.c | 4 ++--
    > 1 files changed, 2 insertions(+), 2 deletions(-)
    >
    > diff --git a/kernel/cgroup.c b/kernel/cgroup.c
    > index 2727f92..e9eb5da 100644
    > --- a/kernel/cgroup.c
    > +++ b/kernel/cgroup.c
    > @@ -406,11 +406,11 @@ static struct css_set *find_css_set(
    >
    > /* First see if we already have a cgroup group that matches
    > * the desired set */
    > - write_lock(&css_set_lock);
    > + read_lock(&css_set_lock);
    > res = find_existing_css_set(oldcg, cgrp, template);
    > if (res)
    > get_css_set(res);
    > - write_unlock(&css_set_lock);
    > + read_unlock(&css_set_lock);
    >
    > if (res)
    > return res;
    > -- 1.5.4.rc3
    >
    >

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. Re: [PATCH] cgroup: use read lock to guard find_existing_css_set()

    Li Zefan wrote:
    > The function does not modify anything (except the temporary
    > css template), so it's sufficient to hold read lock.
    >
    > Signed-off-by: Li Zefan
    > ---
    > kernel/cgroup.c | 4 ++--
    > 1 files changed, 2 insertions(+), 2 deletions(-)
    >
    > diff --git a/kernel/cgroup.c b/kernel/cgroup.c
    > index 2727f92..e9eb5da 100644
    > --- a/kernel/cgroup.c
    > +++ b/kernel/cgroup.c
    > @@ -406,11 +406,11 @@ static struct css_set *find_css_set(
    >
    > /* First see if we already have a cgroup group that matches
    > * the desired set */
    > - write_lock(&css_set_lock);
    > + read_lock(&css_set_lock);
    > res = find_existing_css_set(oldcg, cgrp, template);
    > if (res)
    > get_css_set(res);
    > - write_unlock(&css_set_lock);
    > + read_unlock(&css_set_lock);
    >
    > if (res)
    > return res;


    Looks good to me. Did you run lockdep?



    --
    Warm Regards,
    Balbir Singh
    Linux Technology Center
    IBM, ISTL
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  4. Re: [PATCH] cgroup: use read lock to guard find_existing_css_set()

    Balbir Singh wrote:
    > Li Zefan wrote:
    >> The function does not modify anything (except the temporary
    >> css template), so it's sufficient to hold read lock.
    >>
    >> Signed-off-by: Li Zefan
    >> ---
    >> kernel/cgroup.c | 4 ++--
    >> 1 files changed, 2 insertions(+), 2 deletions(-)
    >>
    >> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
    >> index 2727f92..e9eb5da 100644
    >> --- a/kernel/cgroup.c
    >> +++ b/kernel/cgroup.c
    >> @@ -406,11 +406,11 @@ static struct css_set *find_css_set(
    >>
    >> /* First see if we already have a cgroup group that matches
    >> * the desired set */
    >> - write_lock(&css_set_lock);
    >> + read_lock(&css_set_lock);
    >> res = find_existing_css_set(oldcg, cgrp, template);
    >> if (res)
    >> get_css_set(res);
    >> - write_unlock(&css_set_lock);
    >> + read_unlock(&css_set_lock);
    >>
    >> if (res)
    >> return res;

    >
    > Looks good to me. Did you run lockdep?
    >


    No, I found this when reading the code, but I do have done some test.
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread