Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp503184imm; Mon, 21 May 2018 09:26:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrydDQqLM8LLtlEIbspAcSzMEM5CdN/Ee0qtQjtpmF/Gk3NmHb1Vre72HnKtDaJ9FgSwJWY X-Received: by 2002:a63:a44a:: with SMTP id c10-v6mr16295061pgp.147.1526920006881; Mon, 21 May 2018 09:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526920006; cv=none; d=google.com; s=arc-20160816; b=vm8mPA7/ckkYelkeaZ35P3dHIehvFTiyoCrl1uZdIQQPpHATJ2FAEVk3tog3R7c8bQ kLaZHTG72dmZy1wBZ9w1XgriUl7w+hjlI1y5P8/ppg64GwnoHymyGzHRA/7j6+j4+Wt3 Ih2sRZL7AsvcLtgFIWGvrJrPPTfC1uHgM0yFVrTAJ6Rlsf/53d9JtEcCOGVcZMWph3Iv MIPA/raIqkT/+gHRGE5c1p60eUxeIe818w17DBtA3hMHoOfoRFyrEdGnYOIFvotak6S3 o2JaOkPe+q1AmD2D/gB3oXbjfSoiw+v+Vg9C3poKu0Ho1H39gS5CtdZ4fId38I4CnxfX /3aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=Ix86xOCR6KQ4XqpmZ++ajz7GemoCpT5tDtk4PL/yo9g=; b=wKCPR5AHvBuJo/4fmGtHcKcoRMthcn9sacS8zVSienF0xD/4rc44xi6WifpO0pL6vN vF8H6X5/vw4RHgEVzcCEVJnEoHm34WPPHEQUMAUe8RDgUfx3Ho5C2utSckAtdTydU6WP WqFnovKITeZQe64jM3X+D/mnBrWibsmP3LhRYuGk2JZEwvQnNq7wqPz+3TGE8Cob14Rw +cUkswa1JgjdYQetTheX44OQOnYxUeDyxk43xAZtJvgAXc8g8+9pRlYq6D08sgyoCDtO vERqd/wjJpCsBd1jgcePr1GdYhol/nfwwyORuU7icqpDovoSSaJujK8MRudcv+lNhe2e rglg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pUU2Rnht; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z86-v6si14654755pfa.120.2018.05.21.09.26.31; Mon, 21 May 2018 09:26:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pUU2Rnht; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752948AbeEUQ0S (ORCPT + 99 others); Mon, 21 May 2018 12:26:18 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:46481 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752824AbeEUQ0P (ORCPT ); Mon, 21 May 2018 12:26:15 -0400 Received: by mail-pl0-f68.google.com with SMTP id 30-v6so9081256pld.13; Mon, 21 May 2018 09:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Ix86xOCR6KQ4XqpmZ++ajz7GemoCpT5tDtk4PL/yo9g=; b=pUU2RnhtmXb0DLZEjT5d/4aVJLCa2QgudKzFblawOz+bz3ssB7VmzoLJHSD8eHt2im zsBX6VylZBFGuxiCgUtdmKLg/0zekc5/VpR1hx5l6j8MksKbHhYyhzqyRzjRj0CGcuC0 zp0hKXnza3ImOXc/w1d1JZ7Ef6k2xV/46c22T7WwwL774wBFyw7WUnHb5FiwI+k0kzn4 kbZ+2UEp5baWV+dbAHrxwbz2hW6RSb2RlO0aY80uhdLxxK27IznsSEhtKbiFp8CTu2AW G4iE9G0GcjzKfJq37OpxHw9IGg6b5M0ECCs56j1ofFLhJfXSOSXH0XOh1HRw2erilrkm lklg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Ix86xOCR6KQ4XqpmZ++ajz7GemoCpT5tDtk4PL/yo9g=; b=YRHbHeg/4gxDf519Dweukn2BTx10CqGybiSWya61sxdl+GwwFALI8q8p3CvOWHIgWJ yqriIsPjbffG+clWsgeAX0Vsq+Bylm8RIegW+rMxTnI1K1zenEYlDTEntml/VjjMX0ki IEcW0OmM07HcpLbDu8D7vdFSoRHADY/SoRgVXyUfK1aUpqE/jjqnqy4jBF0LO3eOCpML WQZujtT2AXPiXUzCWHPwpaLysJSBOJ3U0oSk/XqpVBdY9aEfFQIpmKP8duoodUVt7A13 17tHRT7JyXL89BPRZPvGMRGMxXE5NWm9g3CMkcUMtIqtRHQcSnZ0sbinRWYEdvDZInLK c1Sg== X-Gm-Message-State: ALKqPweQOfAahc3Fv+irMVygj8NvZy3hwfVvGamPUAGlPxEdWOL2URvY B2I0i4wM6/yA2SJAWHdGjpZsd20V X-Received: by 2002:a17:902:4101:: with SMTP id e1-v6mr21138100pld.205.1526919975243; Mon, 21 May 2018 09:26:15 -0700 (PDT) Received: from ast-mbp.dhcp.thefacebook.com ([2620:10d:c090:200::7:f099]) by smtp.gmail.com with ESMTPSA id x10-v6sm49504762pfd.162.2018.05.21.09.26.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 09:26:14 -0700 (PDT) Date: Mon, 21 May 2018 09:26:11 -0700 From: Alexei Starovoitov To: Alban Crequy Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, containers@lists.linux-foundation.org, cgroups@vger.kernel.org, Alban Crequy , tj@kernel.org Subject: Re: [PATCH] [RFC] bpf: tracing: new helper bpf_get_current_cgroup_ino Message-ID: <20180521162609.lpdrnozowmzdn57m@ast-mbp.dhcp.thefacebook.com> References: <20180513173318.21680-1-alban@kinvolk.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180513173318.21680-1-alban@kinvolk.io> User-Agent: NeoMutt/20180223 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 13, 2018 at 07:33:18PM +0200, Alban Crequy wrote: > > +BPF_CALL_2(bpf_get_current_cgroup_ino, u32, hierarchy, u64, flags) > +{ > + // TODO: pick the correct hierarchy instead of the mem controller > + struct cgroup *cgrp = task_cgroup(current, memory_cgrp_id); > + > + if (unlikely(!cgrp)) > + return -EINVAL; > + if (unlikely(hierarchy)) > + return -EINVAL; > + if (unlikely(flags)) > + return -EINVAL; > + > + return cgrp->kn->id.ino; ino only is not enough to identify cgroup. It needs generation number too. I don't quite see how hierarchy and flags can be used in the future. Also why limit it to memcg? How about something like this instead: BPF_CALL_2(bpf_get_current_cgroup_id) { struct cgroup *cgrp = task_dfl_cgroup(current); return cgrp->kn->id.id; } The user space can use fhandle api to get the same 64-bit id.