From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08B66C433E2 for ; Wed, 16 Sep 2020 22:27:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B17FB20732 for ; Wed, 16 Sep 2020 22:27:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bcBUT33Y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726433AbgIPW1b (ORCPT ); Wed, 16 Sep 2020 18:27:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50442 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726187AbgIPW11 (ORCPT ); Wed, 16 Sep 2020 18:27:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600295245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hQxDf8JFFogGWBF/VUiJ5CChMgFQy7XyAzV/ZZzgvOY=; b=bcBUT33Yq4dfOeH5VuF8Iitk/qCgdRK8iFZ6NxAjS/uftydBTJpFrel5T2Z+PGzwCLRzgA kw+huil1SKNr/NCG6S6sTbaguDwGWURA+R6uzoq58Uf2etZmzujPPUii/SZbkzdwkMsKOx CSdHT9oHlSq7F2oMfecIzWPy+F/8xWQ= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-494-dm91wSHbOMytOpAjx-QrjA-1; Wed, 16 Sep 2020 17:27:07 -0400 X-MC-Unique: dm91wSHbOMytOpAjx-QrjA-1 Received: by mail-wr1-f69.google.com with SMTP id 33so3073895wre.0 for ; Wed, 16 Sep 2020 14:27:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=hQxDf8JFFogGWBF/VUiJ5CChMgFQy7XyAzV/ZZzgvOY=; b=EtXt3oulVw3G9ZLnKtsTc/ldGvGLkJrB3dydYHwb8o9IyeDU8owDOXUJYzhFVnU6Ec tkIw26LwGSSrrFg4CxGAP4t6y8B1r4OfQw55ee7ey83R6bx1Jawvfmcu17BCkFQtIgWO UWM0280VdnUmZFkch/isUPEvLUqELt0MWIKOkt6xNh5r02C1T2ChMSek5CtUFmB49bY8 LgV795Ls/+mcXVrDQjoYaAPqkXCJRHWAOfW45YpyS0uXutonKI6SVyMODpGwbwBYrUX1 FAMvbvzZwXcU6lBbDn/+7JjTSGd7cjX6ALVk+fgSy3ydhBY/Okp5IVb1XotWr7lC+W2x xB5g== X-Gm-Message-State: AOAM530AWscX4GZewwnfVaRZzZ1Onv9bHcLaBusQHjbPpfUa+j7IoKZN ROAMqyW6dezNdBZstm698V76foSvO2usnO09LkjsEVLANq7AYG36gOt7iTyIk1u+3Eu3+1Qs3s/ XIFirMRYBLqTX6TZj X-Received: by 2002:a7b:c341:: with SMTP id l1mr6867924wmj.80.1600291625773; Wed, 16 Sep 2020 14:27:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/SkXRCKaZasukIexmx8qH+ipJwS/1Eihx9dlzAbJ4izLrfzMv9BtsY4zH1JWxRmOHLuFNfw== X-Received: by 2002:a7b:c341:: with SMTP id l1mr6867893wmj.80.1600291625439; Wed, 16 Sep 2020 14:27:05 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id t22sm8919184wmt.1.2020.09.16.14.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 14:27:04 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 86742183A90; Wed, 16 Sep 2020 23:27:04 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Andrii Nakryiko Cc: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , Jiri Olsa , Eelco Chaudron , KP Singh , Networking , bpf Subject: Re: [PATCH bpf-next v5 4/8] bpf: support attaching freplace programs to multiple attach points In-Reply-To: References: <160017005691.98230.13648200635390228683.stgit@toke.dk> <160017006133.98230.8867570651560085505.stgit@toke.dk> <87r1r1pgr5.fsf@toke.dk> X-Clacks-Overhead: GNU Terry Pratchett Date: Wed, 16 Sep 2020 23:27:04 +0200 Message-ID: <87een1pg47.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Andrii Nakryiko writes: > On Wed, Sep 16, 2020 at 2:13 PM Toke H=C3=B8iland-J=C3=B8rgensen wrote: >> >> >> [ will fix all your comments above ] >> >> >> @@ -3924,10 +3983,16 @@ static int tracing_bpf_link_attach(const unio= n bpf_attr *attr, struct bpf_prog * >> >> prog->expected_attach_type =3D=3D BPF_TRACE_ITER) >> >> return bpf_iter_link_attach(attr, prog); >> >> >> >> + if (attr->link_create.attach_type =3D=3D BPF_TRACE_FREPLACE && >> >> + !prog->expected_attach_type) >> >> + return bpf_tracing_prog_attach(prog, >> >> + attr->link_create.targ= et_fd, >> >> + attr->link_create.targ= et_btf_id); >> > >> > Hm.. so you added a "fake" BPF_TRACE_FREPLACE attach_type, which is >> > not really set with BPF_PROG_TYPE_EXT and is only specified for the >> > LINK_CREATE command. Are you just trying to satisfy the link_create >> > flow of going from attach_type to program type? If that's the only >> > reason, I think we can adjust link_create code to handle this more >> > flexibly. >> > >> > I need to think a bit more whether we want BPF_TRACE_FREPLACE at all, >> > but if we do, whether we should make it an expected_attach_type for >> > BPF_PROG_TYPE_EXT then... >> >> Yeah, wasn't too sure about this. But attach_type seemed to be the only >> way to disambiguate between the different link types in the LINK_CREATE >> command, so went with that. Didn't think too much about it, TBH :) > > having extra attach types has real costs in terms of memory (in cgroup > land), which no one ever got to fixing yet. And then > prog->expected_attach_type !=3D link's expected_attach_type looks weird > and wrong and who knows which bugs we'll get later because of this. > >> >> I guess an alternative could be to just enforce attach_type=3D=3D0 and l= ook >> at prog->type? Or if you have any other ideas, I'm all ears! > > Right, we have prog fd, so can get it (regardless of type), then do > switch by type, then translate expected attach type to prog type and > see if it matches, but only for program types that care (which right > now is all but tracing, where it's obvious from prog_type alone, I > think). Right, makes sense; will do that in the next version! -Toke