From: Tejun Heo <tj@kernel•org>
To: Andrey Ignatov <rdna@fb•com>
Cc: netdev@vger•kernel.org, ast@kernel•org, daniel@iogearbox•net,
guro@fb•com, kernel-team@fb•com
Subject: Re: [PATCH bpf-next 1/4] bpf: Introduce bpf_skb_ancestor_cgroup_id helper
Date: Mon, 13 Aug 2018 07:46:35 -0700 [thread overview]
Message-ID: <20180813144635.GI3978217@devbig004.ftw2.facebook.com> (raw)
In-Reply-To: <b7abb909209e02651d873d90fe8825b432c73f0e.1533965421.git.rdna@fb.com>
Hello, Andrey.
On Fri, Aug 10, 2018 at 10:35:23PM -0700, Andrey Ignatov wrote:
> +static inline struct cgroup *cgroup_ancestor(struct cgroup *cgrp,
> + int ancestor_level)
> +{
> + struct cgroup *ptr;
> +
> + if (cgrp->level < ancestor_level)
> + return NULL;
> +
> + for (ptr = cgrp;
> + ptr && ptr->level > ancestor_level;
> + ptr = cgroup_parent(ptr))
> + ;
> +
> + if (ptr && ptr->level == ancestor_level)
> + return ptr;
> +
> + return NULL;
> +}
I don't have any objections functionanlity-wise but can we do sth like
the following instead?
static inline struct cgroup *cgroup_ancestor(struct cgroup *cgrp,
int ancestor_level)
{
if (cgrp->level < ancestor_level)
return NULL;
while (cgrp->level > ancestor_level)
cgrp = cgroup_parent(cgrp);
return cgrp;
}
Thanks.
--
tejun
next prev parent reply other threads:[~2018-08-13 17:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-11 5:35 [PATCH bpf-next 0/4] bpf_skb_ancestor_cgroup_id helper Andrey Ignatov
2018-08-11 5:35 ` [PATCH bpf-next 1/4] bpf: Introduce " Andrey Ignatov
2018-08-13 14:46 ` Tejun Heo [this message]
2018-08-13 15:39 ` Andrey Ignatov
2018-08-11 5:35 ` [PATCH bpf-next 2/4] bpf: Sync bpf.h to tools/ Andrey Ignatov
2018-08-11 5:35 ` [PATCH bpf-next 3/4] selftests/bpf: Add cgroup id helpers to bpf_helpers.h Andrey Ignatov
2018-08-11 5:35 ` [PATCH bpf-next 4/4] selftests/bpf: Selftest for bpf_skb_ancestor_cgroup_id Andrey Ignatov
2018-08-12 6:58 ` Yonghong Song
2018-08-12 17:41 ` Andrey Ignatov
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=20180813144635.GI3978217@devbig004.ftw2.facebook.com \
--to=tj@kernel$(echo .)org \
--cc=ast@kernel$(echo .)org \
--cc=daniel@iogearbox$(echo .)net \
--cc=guro@fb$(echo .)com \
--cc=kernel-team@fb$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=rdna@fb$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox