From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tejun Heo Subject: Re: [PATCH bpf-next 1/4] bpf: Introduce bpf_skb_ancestor_cgroup_id helper Date: Mon, 13 Aug 2018 07:46:35 -0700 Message-ID: <20180813144635.GI3978217@devbig004.ftw2.facebook.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: netdev@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, guro@fb.com, kernel-team@fb.com To: Andrey Ignatov Return-path: Received: from mail-yw1-f66.google.com ([209.85.161.66]:44439 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729478AbeHMR3M (ORCPT ); Mon, 13 Aug 2018 13:29:12 -0400 Received: by mail-yw1-f66.google.com with SMTP id l9-v6so13714876ywc.11 for ; Mon, 13 Aug 2018 07:46:38 -0700 (PDT) Content-Disposition: inline In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: 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