Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp377092ybl; Mon, 2 Dec 2019 12:07:04 -0800 (PST) X-Google-Smtp-Source: APXvYqx96nXD9ql4amAiQF080aeDvVWO0ekm4ujBO9Q+UIw7XLC/8prVfdg2UiNtA1TGNCjRQYV/ X-Received: by 2002:a50:de47:: with SMTP id a7mr866946edl.77.1575317224688; Mon, 02 Dec 2019 12:07:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575317224; cv=none; d=google.com; s=arc-20160816; b=GvtuZ+7eLe/OD+BikyxQvdO/ajmlNeXmj50aObaR8zfLekYxqUEvErA534vZH1yaVW FrYRhNkthJVjGiZ9WXKKyop2T8rRbTppNNcAXn78tHa3WGpPkxaEj5Id2Nq8ZNrDLjPs rAjpbZ1SW+HFPU4wd4hzeo03AWkihhwQCotq4vPqXE9Uvb2LZopHJmkVlULCme+nam1A jftfZmAY2rW7Zi6bzvca3RsX4ERHve9V/WkbPGjUKdxT6ACqVPJnzekDZfjAniCRRDl/ ElHQfRsVWrQV6BJL5PirPVJBC+yM/ukNSh9FQONGl4UbKt15GVuJt+KlZthvqTpC/pwJ cgmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EahjHtPxa0IRKLg7rJztVt75g0Mh1O3hEHuZpwDPvYg=; b=l03dYleLkP5xcy0+MCUjQ4AMwaNZyuvh+doqssEc1aUE2qCd7fWNw/6B7ykPJYyjKG j+A2dyPBfNoJ3kCDiT0DLAih4BbOEztuBvVTokDi0G90TlElnn6WR6MPqnAMrqQbKaz8 TnBFXgPsp99fIazTw4xuP5k7SGJZX5TX+qDwLoOivUkdtRSujkvperJYX4MJZrdbyZhE vBPJ/Bw2uHvx4c/yHBuul/wBpZbySFV8tO11k6pQEul2dN7+RLIOsmcomGj5nZ/jddTM VPAc8zQzw8Hyf0vSgeEI623En7ytb0/aTpRcb+8THDrR5+1aPXJjIeinqId1uPkkDnta MRxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NiZYzFLi; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j11si403462edn.124.2019.12.02.12.06.26; Mon, 02 Dec 2019 12:07:04 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=NiZYzFLi; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728091AbfLBUC4 (ORCPT + 99 others); Mon, 2 Dec 2019 15:02:56 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:26035 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727976AbfLBUC4 (ORCPT ); Mon, 2 Dec 2019 15:02:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575316974; 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=EahjHtPxa0IRKLg7rJztVt75g0Mh1O3hEHuZpwDPvYg=; b=NiZYzFLiPqlnSu/NNoKVFW7jVAInZWxyKHGFD0/3kN8PiuF19A4xRbt8ATbkYfQrLPAjAM vlA/DPflBfzIX8zlShRgi/oNTTbHc/snom4rN4/9SI5rYZmmKRjnrVqtvu9/UuyPAR6ww0 iV14fjIxdYucGmx+ukyoMxPICGIDuBo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-146-39vGrJ5NP5uyOA_Wex8FWg-1; Mon, 02 Dec 2019 15:02:53 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E4FF800D41; Mon, 2 Dec 2019 20:02:51 +0000 (UTC) Received: from krava (ovpn-204-100.brq.redhat.com [10.40.204.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A37FB5DA2C; Mon, 2 Dec 2019 20:02:42 +0000 (UTC) Date: Mon, 2 Dec 2019 21:02:41 +0100 From: Jiri Olsa To: Andrii Nakryiko Cc: Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?= , Jiri Olsa , Arnaldo Carvalho de Melo , lkml , Networking , bpf , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan , Jesper Dangaard Brouer , Daniel Borkmann , Alexei Starovoitov , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko Subject: Re: [PATCH 0/3] perf/bpftool: Allow to link libbpf dynamically Message-ID: <20191202200241.GB22100@krava> References: <20191127094837.4045-1-jolsa@kernel.org> <87zhgappl7.fsf@toke.dk> <20191202192122.GA22100@krava> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 39vGrJ5NP5uyOA_Wex8FWg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 02, 2019 at 11:54:27AM -0800, Andrii Nakryiko wrote: > On Mon, Dec 2, 2019 at 11:21 AM Jiri Olsa wrote: > > > > On Mon, Dec 02, 2019 at 10:42:53AM -0800, Andrii Nakryiko wrote: > > > On Mon, Dec 2, 2019 at 10:09 AM Toke H=F8iland-J=F8rgensen wrote: > > > > > > > > Andrii Nakryiko writes: > > > > > > > > > On Wed, Nov 27, 2019 at 1:49 AM Jiri Olsa wrot= e: > > > > >> > > > > >> hi, > > > > >> adding support to link bpftool with libbpf dynamically, > > > > >> and config change for perf. > > > > >> > > > > >> It's now possible to use: > > > > >> $ make -C tools/bpf/bpftool/ LIBBPF_DYNAMIC=3D1 > > > > > > > > > > I wonder what's the motivation behind these changes, though? Why = is > > > > > linking bpftool dynamically with libbpf is necessary and importan= t? > > > > > They are both developed tightly within kernel repo, so I fail to = see > > > > > what are the huge advantages one can get from linking them > > > > > dynamically. > > > > > > > > Well, all the regular reasons for using dynamic linking (memory usa= ge, > > > > binary size, etc). > > > > > > bpftool is 327KB with statically linked libbpf. Hardly a huge problem > > > for either binary size or memory usage. CPU instruction cache usage i= s > > > also hardly a concern for bpftool specifically. > > > > > > > But in particular, the ability to update the libbpf > > > > package if there's a serious bug, and have that be picked up by all > > > > utilities making use of it. > > > > > > I agree, and that works only for utilities linking with libbpf > > > dynamically. For tools that build statically, you'd have to update > > > tools anyways. And if you can update libbpf, you can as well update > > > bpftool at the same time, so I don't think linking bpftool statically > > > with libbpf causes any new problems. > > > > it makes difference for us if we need to respin just one library > > instead of several applications (bpftool and perf at the moment), > > because of the bug in the library > > > > with the Toke's approach we compile some bits of libbpf statically into > > bpftool, but there's still the official API in the dynamic libbpf that > > we care about and that could carry on the fix without bpftool respin >=20 > See my replies on v4 of your patchset. I have doubts this actually > works as we hope it works. >=20 > I also don't see how that is going to work in general. Imagine > something like this: >=20 > static int some_state =3D 123; >=20 > LIBBPF_API void set_state(int x) { some_state =3D x; } >=20 > int get_state() { return some_state; } >=20 > If bpftool does: >=20 > set_state(42); > printf("%d\n", get_state()); >=20 >=20 > How is this supposed to work with set_state() coming from libbpf.so, > while get_state() being statically linked? Who "owns" memory of `int > some_state` -- bpftool or libbpf.so? Can they magically share it? Or > rather maybe some_state will be actually two different variables in > two different memory regions? And set_state() would be setting one of > them, while get_state() would be reading another one? >=20 > It would be good to test this out. Do you mind checking? I think you're right.. sry, I should have checked on this more, there are no relocations for libbpf.so, so it's all statically linked and the libbpf is just in 'needed' libs record.. ugh :-\ jirka