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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 453DDC3DA49 for ; Thu, 25 Jul 2024 20:04:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D56226B008C; Thu, 25 Jul 2024 16:04:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D050D6B0092; Thu, 25 Jul 2024 16:04:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCC486B0093; Thu, 25 Jul 2024 16:04:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9DCAB6B008C for ; Thu, 25 Jul 2024 16:04:15 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5D8EA1C0465 for ; Thu, 25 Jul 2024 20:04:15 +0000 (UTC) X-FDA: 82379351670.13.14A30DD Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by imf02.hostedemail.com (Postfix) with ESMTP id 8486880004 for ; Thu, 25 Jul 2024 20:04:13 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Wcosu/3G"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of andrii.nakryiko@gmail.com designates 209.85.218.46 as permitted sender) smtp.mailfrom=andrii.nakryiko@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721937852; a=rsa-sha256; cv=none; b=NVscycWzkEV7aqYhLCbAdmim8Lu8zG+hZBr1COsJ31Zfh/Yoe9sIgAXaKgAakmmBgeTuPn 6/3OWiQxYNgUo3eEX7/YimPcT5t7jTrWIgOg6RoLt6OrNBGqUX7PTFHhAsVzTwTp/Mb5iR n2J4LKpfc8XKOhGo1vgW/Fv9+I2I728= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Wcosu/3G"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of andrii.nakryiko@gmail.com designates 209.85.218.46 as permitted sender) smtp.mailfrom=andrii.nakryiko@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721937852; h=from:from:sender: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:dkim-signature; bh=keV/f2SuMyG9IehGIqscrvt7JW23HPRIqoZZs3j3whE=; b=shmOwI7DhvPW974HrWOLd29rcTiaNwAquYD5/zrlyuHRt1+w69INBScP/RK0+An2bMNoMV eiIKx3hJb1asbv3CnafSSPZg3O6ITc6hV9zYQjv5F5EeLwrnYNYPHVzXYoJOQuzly+ofIl my0sVlJw2aCOGVI/jpz7WYmcX4Fpv7o= Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a7a9a7af0d0so128534366b.3 for ; Thu, 25 Jul 2024 13:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721937852; x=1722542652; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=keV/f2SuMyG9IehGIqscrvt7JW23HPRIqoZZs3j3whE=; b=Wcosu/3GRzMsS0+eZbXvbxHF60SQJVA9Wi0NHt0nYALkEzNOl1cqp+/MTKya65ZH6/ bKJZhPjns6JhL6qIfbDYCwSvx7w5QSa4Td7Wb3zrLPTGGLr0na6iMcpGO2AoViwKNdf5 DyICarh5DohgOFqJ4kyZdVrw1jEwoPKIkSWMBtxf0bU0zaIQkUaEPxfXfmCBA2dGspqV M3mLFZSzkWGqTnuGLGIqCluV0+T0wpT+8jKj+Pci47GpVS5QrqSYNgP5pHorbPCUN8w8 9pFdb0oryFKYKixP2R6Ls74QCa3q8LRZz7OXVG9VIboS4q2/RoQaMiEqGEU9rowDMNvT zZJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721937852; x=1722542652; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=keV/f2SuMyG9IehGIqscrvt7JW23HPRIqoZZs3j3whE=; b=wqB6qGfugCqq6ooJ487v1oFXJ4gGi3PqhN4b9QtT51Jo+c96uCF/iXOM1HGMHJ2IYz oDPxDtbcA6oCZWcO86TtDMF1NOq9Khwza8DmHn8zTPPLIxh+iy4u857I9O2iK8PLhrue OCH1x3xEfm2thgc/A8DQ2Rok3x8U6ZUyoI+l6Ny1Yxi7FhBSs0E4Hk5bLzCHkFiKlsU1 nE3x+GZk/etE0wDMcQ22e7/lJzHqRowXmub9QhEL9I1pdqGPdz2HuYp0F6meIB7laAf8 KzrKQziWG0aOKbKtp5EuzZIuJUBgTC+XcuvfDh1Pp6jM+5CCxGvo40WPhMkZl0wcCiqa NwTw== X-Forwarded-Encrypted: i=1; AJvYcCUOlqHRNVu6hekpE1QvzgT6zx7k6f0yApcfE9sZi9YnQbEayCuVOnuIdI5x3K3UB1H5A/fxZUx3BK+YiXH2/mYvcrE= X-Gm-Message-State: AOJu0YzOyFCjchskORI6HCvMTsO9oz243mM1idjdtwobWpGuh/lqvyXW 1TCjL9M7JtqReV/86ihSg29BePfKO6fp22mXSmZRHCA3FGjbp2J73tl/CgFR00xu+vL6hPltT4g ptPFEHL/c2NC9UOAR+HQu2rNLHT4= X-Google-Smtp-Source: AGHT+IFQuNq4+ITcXQALOODQTbirZQmDVSWKplJTCsq20BRgNzMCoo+CUfEi/wFOHqzNVaUmwOAYb6PpsLB7bM/WmBM= X-Received: by 2002:a17:907:d86:b0:a7a:9ca6:527 with SMTP id a640c23a62f3a-a7acb3d9eb3mr237670866b.8.1721937851452; Thu, 25 Jul 2024 13:04:11 -0700 (PDT) MIME-Version: 1.0 References: <20240724225210.545423-1-andrii@kernel.org> <20240724225210.545423-11-andrii@kernel.org> In-Reply-To: From: Andrii Nakryiko Date: Thu, 25 Jul 2024 13:03:55 -0700 Message-ID: Subject: Re: [PATCH v2 bpf-next 10/10] selftests/bpf: add build ID tests To: Jiri Olsa Cc: Andrii Nakryiko , bpf@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, adobriyan@gmail.com, shakeel.butt@linux.dev, hannes@cmpxchg.org, ak@linux.intel.com, osandov@osandov.com, song@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Queue-Id: 8486880004 X-Rspamd-Server: rspam01 X-Stat-Signature: gy1swjzcdwiid9hfnghu17zswapgitoe X-HE-Tag: 1721937853-734393 X-HE-Meta: U2FsdGVkX19PHEYX+y8NWw/TBa4m05VEysDUa5E15VpYZlDJ/xPRSXwq+F/Ta0UdYaS01/NEyzby50O90AWibi+bwu8sYVN6hHov96WgtG63LspEbJmzCq6ZxQdFraXZPgw+wRIaFDfkUHHEQviNyH8lvH8Z/nf+/xlSrPsCwKfvagzTNeshCvrVPNa6LvWvk4vX0M6kgnH5xX38QYNjhpzRJPIc0V7YhKHx0729caRTDiPAkIT6fDjzX/UNvy0kBvJUOY9+DbdFu4uLHNw7vBPkRoB+IpfW7xf65fF5FJaDL0013Lps+maq0a2RARvLMxh537SzCs2/oKUhZX6LLdKfz8bJnoWpwV+XZGJHVsI99jPyVwa7qL9LYbhTa4OCD/L0J121/TROmi+C+M/LsFAyeWo0bc7R7ml5zeCLrwP11xnV47ttYQx20cFPusXz7yUGAEfz20N5To/vpJyvofRVkKbw3IpLvKkVNlysx1ngnx79urLUPl54zC5D+Sd6ChUSSEzDSxDOaxy1jvzSqkLb/0p9AmNZVpBR+8koN9DYNNpj3wJ9igJlvA508VwMMk/ZAH64VCbDlvSAIvrhgkyVTIWimEfZ+EQ5DP3A4NdXhX+AZplQyMvzm4gatemQUfaYcwuWBjbVRBHu1Wz4647r/1SFWA+85XfabquXpMXQJqpTDeljn4toFovLfsNSavrIT0O9M9zsBW3VpbynQAf6dz/QqA7HqOU7ZU+MtEgiKBoBEbFEXobQfV4Dwg67dwsdCZgq2zXxMDk4anoGpNHzN8cRCDPHFJgStzded9oEVu1UqJcANWxXWMfkFXbDZQj11FBsIXq02rHX+29Rdhss4sqrtctw2PzZPYwyRutulAhf2J5mdzxEeNBmsRvDNfy8GjYmPAxelJZh3eku2+CdzkQoLEcrJy/3rJnCkVwVvfIiNFN0lMCAzcKP1n8qEiErpFfOyv4lnAD4cmK c6B20GZV DpubHqjCAHTmaTFrveG6VrhNJeNJOGwn9B3zI2p2OpbbighMix5Ca+9Peb6ZVclFpl0k1eeu5zMI8uv2tSxZw5IVyCk0XDYRBhOT8OokEbn3ll3olBcsqBUhEHuYSwlksM1Id1UAfXM74SzpRgEOli3hgsEpVBm46nbbC8S0OvjfmRwwn9WtW5QPukzf0T+AAnc35llu6NbjP942KiJxmgv78ef6gnRr/91tB0u54BGehXPZx70UbVLdIlq+hAFIxvMMN1TereuIY+ko7wPZm30Qch0ztTTgBqqqTIsJZYaLtWsdUrzxesU57vjEdABEmwxL7NUW6BCUk+rA16xTZafk0qJXApYiJzeVajttAuX+nq4rNdtbJv2RBFihBCrP8tpvt9fE/rZ3zvbj36fnDM+DcWPGNs5DirBZN X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Jul 25, 2024 at 5:12=E2=80=AFAM Jiri Olsa wrot= e: > > On Wed, Jul 24, 2024 at 03:52:10PM -0700, Andrii Nakryiko wrote: > > Add a new set of tests validating behavior of capturing stack traces > > with build ID. We extend uprobe_multi target binary with ability to > > trigger uprobe (so that we can capture stack traces from it), but also > > we allow to force build ID data to be either resident or non-resident i= n > > memory (see also a comment about quirks of MADV_PAGEOUT). > > > > That way we can validate that in non-sleepable context we won't get > > build ID (as expected), but with sleepable uprobes we will get that > > build ID regardless of it being physically present in memory. > > > > Also, we add a small add-on linker script which reorders > > .note.gnu.build-id section and puts it after (big) .text section, > > putting build ID data outside of the very first page of ELF file. This > > will test all the relaxations we did in build ID parsing logic in kerne= l > > thanks to freader abstraction. > > > > Signed-off-by: Andrii Nakryiko > > one of my bpf selftests runs showed: > > test_build_id:PASS:parse_build_id 0 nsec > subtest_nofault:PASS:skel_open 0 nsec > subtest_nofault:PASS:link 0 nsec > subtest_nofault:PASS:trigger_uprobe 0 nsec > subtest_nofault:PASS:res 0 nsec > subtest_nofault:FAIL:build_id_status unexpected build_id_status: actual 1= !=3D expected 2 > #42/1 build_id/nofault-paged-out:FAIL > #42/2 build_id/nofault-paged-in:OK > #42/3 build_id/sleepable:OK > #42 build_id:FAIL > > I could never reproduce again.. but I wonder the the page could sneak > in before the bpf program is hit and the buildid will get parsed? > Yes, and I just realized that I forgot to mark this test as serial. If there is parallel test that also runs uprobe_multi and that causes build_id page to be paged in into page cache, then this might succeed. So I need to mark the test itself serial. Another issue which I was debugging (and fixed) yesterday was that if the memory passed for MADV_PAGEOUT is not yet memory mapped into the current process, then it won't be really removed from the page cache. I avoid that by first paging it in, and then MADV_PAGEOUT. > or maybe likely madvise might just ignore that: > > MADV_PAGEOUT (since Linux 5.4) > Reclaim a given range of pages. This is done to free up me= mory occupied by these pages. If a page is anonymous, it will be swapped o= ut. If > a page is file-backed and dirty, it will be written bac= k to the backing storage. The advice might be ignored for some pages in th= e range > when it is not applicable. > > jirka > > > > --- > > tools/testing/selftests/bpf/Makefile | 5 +- > > .../selftests/bpf/prog_tests/build_id.c | 118 ++++++++++++++++++ > > .../selftests/bpf/progs/test_build_id.c | 31 +++++ > > tools/testing/selftests/bpf/uprobe_multi.c | 41 ++++++ > > tools/testing/selftests/bpf/uprobe_multi.ld | 11 ++ > > 5 files changed, 204 insertions(+), 2 deletions(-) > > create mode 100644 tools/testing/selftests/bpf/prog_tests/build_id.c > > create mode 100644 tools/testing/selftests/bpf/progs/test_build_id.c > > create mode 100644 tools/testing/selftests/bpf/uprobe_multi.ld > > [...]