Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796414687; b=zn1CLUhXS7KZkYB3uwRyihTRrc7k6JDYJI56OG/t7WiyS+3R5s7uESmyCgKIM3Gctb+0 0vchMn0lZMDxC7Z/p3pe3M10oH8+zRXRN59V3lHHx2nIUsMoWPM5fF5vKz9GKkHdfLVdm x2JfXSBSkK1XWOWI6EG/A+q0wEnctI3yMAK0sWywANOxe9S05hr62wuriGc6Hc5n5pNqo 7TbnfIkFCd7DN3baqhbcUyNY99n4pgZE21mqlzZWPzPSJw5hgrQnTFC/d4ZT8lj9JFv/Z VJR5ho8/5vURM+X3iCn0s38kLwwC7wN6VQaPLl643OV7Q3hPON4z2BBe7c1CVMQnGHA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796414687; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:Date:Subject: MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id: References:In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature: X-Developer-Key; bh=h3huxi+blyDZTUAek08Yp06Dvl6fplLy8/abTX5ir5Y=; b=t6HYBWM2Q2ibthxGrTCNkC0i1GEryHzewQZXazmJHzwn3F6WxUY6BtrMTXM4hAUale/K WDwJJAK7FGDrxWWsRoanPu8iaNb6enwD37f5jRLvJ9Cv8wx/WwDhXcWy8Z52t6RbGRyxW to4vqGVLjmQD7qrUuuhq9JeQwRhZMSeYjVVfAdGv96hZpoz7y1bw+AbeVnHilzWRvaZ8I i320+DRX+shlDRcNNGA6nsvYSMYhr210YQPgh3W+I8wsktPRUblOmVwWAKVJ8Cf0N6846 +eN7Eyb+NXfr/LNOr3/A35M+Ydc2+I5iynNhi7IB90okyH4lArbWmLAdS9lWKcTQb8w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=cqh4xXM5; arc=none smtp.remote-ip=209.85.128.182 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3B34606A322 for ; Fri, 4 Dec 2026 20:04:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C3B34606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=cqh4xXM5 Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-8b3402105b9so9879857b3.0 for ; Fri, 04 Dec 2026 12:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796414686; x=1797019486; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=h3huxi+blyDZTUAek08Yp06Dvl6fplLy8/abTX5ir5Y=; b=cqh4xXM5dtC7IcCNyum37dfQMHLBCvXMCaDJqYnpP0v9MTp1xpdaOLr0LrRVqQnAqL wwxjtwvuQ9eRfBxt8t7O94alQuIxX+lf0XG5sBHZl6Y7TkBFxU4vTzwBBUpUt6FY9Vp/ N6iS7Mu3UjTIiSg0r24/MEvDOdP9wXvyq6lW/WldqQkh5llCbXNRhN+BMWuVb9POHZbh uKsdHUHAOpVMKGnoJ71CbiUbvLgJ0qB6HbqXu0oSm9s0dxRxP9OW+h0CoujsiGiq43Pg 2ir85aX8Jwa12TIm7+552K9ZCNu03nWSvT5ad67UDFx8n3ugZcpqbhicWUrp1BwgLY4t nvzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796414686; x=1797019486; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=h3huxi+blyDZTUAek08Yp06Dvl6fplLy8/abTX5ir5Y=; b=BYnVRf7e0mVn118mjM+uuc4z446dvY+WbFFDXEUiT6jNtDrTusSIuUNWIEyiMJNGLj JQltK0JgyEjVUm6hlCYUh2bJ6yKTfQ7BFyyHhrUlFnteKC1e6k/wZlRw2tyUfeXZ8GsT qdxQGn0ahy3r5qXya3MjoJhC0dQ2flsfic35blrgJ4+Dy1AZcL6U5pSjlr453cwA8rqQ hWvIK8rwsb0JxwEoU0cD1ITHCLRswfB28cBtQVBMnz9Va3LhwEETiWFRIhuOFfx61ZjZ z/IyA8gycqgEStoLzY37hEM/RwShoClpUyVUPRqJwUEcpKCImrI6awnljHw8ZodTrG60 9GGw== X-Gm-Message-State: AB4q+uGvv9aYAZKY3xjDvJbMxgUoo6HhraG1rzH928278dUuySADP5tq E8bId5p7hqHgnbJhrpg7R3P3U+KmX1rVnHUa352TlAXR6T7+kwrZRX9X X-Gm-Gg: AZFdTZfquR62PhePyTpHNEhvbU9UzoTYOagDghVES2JnnXfQxyyIf5WNd061ydwknDo iQkM/FFII/i3KpeUThMGqZvOUcOKqnSdeZ9O9Vmau4N/Wpj+vwwRyh4HV/mlOJK2eFYZyaYLVQ+ jOAzLLspZg1CYtNcKPQTJRw/nOJDj2WSmECFedZAIJo7qAWYZrH7wNeDYGbc3UFIjttu5cwKicE fWXRcjNqabVSsbEThc4Z0CXt4Zm3I/ZuxRSSED3nEEtCa1dDgcUWya6jWEi6O57ofSe8CXQFgM9 Uko+ll/M2SZkcEIvdY07d/n0Cizt4v2o6l1IhgHenTPKVOJFN3OPs849qhwXjmQsfZqtQXPxxVi vRiPD98ThJN0Sl07w6Jie+qdiQtZqQn1y8Rl+oaJevv9NqiOLTkPSgKKaiLbVOCNIZ2W5gtAdml 4k8XWJsy8TYng+JFba23a1f+Apbq74xhyNxBEUgJPmkO3MI50dseHfeR3Wd6ZW0rPbyfqFAinY4 6CDhggWrIA+gGd2XozDlG47IsilLoNXw+KdWYlgp5ql3UKumjjfxlxdDsgcIbaRcNlXATQFw3fv TeDrMAuaj8ri+WOTHL0l X-Received: by 2002:a05:690c:9b02:b0:8ab:422f:a8a3 with SMTP id 00721157ae682-8b660dffa9emr12438667b3.104.1796414685898; Fri, 04 Dec 2026 12:04:45 -0800 (PST) Received: from localhost ([2a03:2880:30ff:74::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b660db406asm14392407b3.31.2026.12.04.12.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 12:04:45 -0800 (PST) From: Mykyta Yatsenko Date: Fri, 04 Dec 2026 12:03:53 -0800 Subject: [PATCH bpf-next 2/5] selftests/bpf: Test sk storage maps that share cache slots X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261204-sk_storage_prefetch-v1-2-ea52fb48b52b@meta.com> References: <20261204-sk_storage_prefetch-v1-0-ea52fb48b52b@meta.com> In-Reply-To: <20261204-sk_storage_prefetch-v1-0-ea52fb48b52b@meta.com> To: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net, kernel-team@meta.com, eddyz87@gmail.com, memxor@gmail.com Cc: Mykyta Yatsenko X-Mailer: b4 0.16-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1796414679; l=2476; i=yatsenko@meta.com; s=20260324; h=from:subject:message-id; bh=YqhlpfvTiwdgldp4QYJy5w21CcI9Z43UAEFE9FQ0M/8=; b=7Hy441a0GyMHsNn9/IGdH+G551MMpTToWcg1wzdyjL51/4eCfQG3wGOzC0nST0oRJqCkL/gNS I8DIFBlxSHRBKSoHo2etttGXqfT8wPstKYVbCJrgpt428BEBIYAUeo3 X-Developer-Key: i=yatsenko@meta.com; a=ed25519; pk=1zCUBXUa66KmzfjNsG8YNlMj2ckPdqBPvFq2ww3/YaA= From: Mykyta Yatsenko A NULL cache[] slot now means that the storage has no element for the slot, so a delete must refill the slot from the other elements. Use more maps than slots, and check the other lookups after each delete. Signed-off-by: Mykyta Yatsenko --- .../bpf/prog_tests/sk_storage_shared_slots.c | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/sk_storage_shared_slots.c b/tools/testing/selftests/bpf/prog_tests/sk_storage_shared_slots.c new file mode 100644 index 0000000000000..d75b0f6115f5d --- /dev/null +++ b/tools/testing/selftests/bpf/prog_tests/sk_storage_shared_slots.c @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include + +/* More maps than the 16 cache[] slots, so that maps share slots */ +#define NR_MAPS 20 + +void test_sk_storage_shared_slots(void) +{ + LIBBPF_OPTS(bpf_map_create_opts, opts, .map_flags = BPF_F_NO_PREALLOC, + .btf_key_type_id = 1, .btf_value_type_id = 1); + int fds[NR_MAPS], sk = -1, n = 0, i, j, val; + struct btf *btf; + + /* sk storage maps need BTF for the key and the value: type 1 is int */ + btf = btf__new_empty(); + if (!ASSERT_OK_PTR(btf, "btf__new_empty")) + return; + btf__add_int(btf, "int", 4, BTF_INT_SIGNED); + if (!ASSERT_OK(btf__load_into_kernel(btf), "btf__load_into_kernel")) + goto out; + opts.btf_fd = btf__fd(btf); + for (n = 0; n < NR_MAPS; n++) { + fds[n] = bpf_map_create(BPF_MAP_TYPE_SK_STORAGE, NULL, 4, 4, 0, + &opts); + if (!ASSERT_OK_FD(fds[n], "bpf_map_create")) + goto out; + } + sk = socket(AF_INET6, SOCK_STREAM, 0); + if (!ASSERT_OK_FD(sk, "socket")) + goto out; + for (i = 0; i < NR_MAPS; i++) + ASSERT_OK(bpf_map_update_elem(fds[i], &sk, &i, BPF_NOEXIST), + "update"); + + /* + * A link puts its element in the slot, so the last maps hold the shared + * slots. Delete these maps first: each delete must refill the slot. + */ + for (i = NR_MAPS - 1; i >= 0; i--) { + ASSERT_OK(bpf_map_delete_elem(fds[i], &sk), "delete"); + ASSERT_EQ(bpf_map_lookup_elem(fds[i], &sk, &val), -ENOENT, + "lookup deleted"); + for (j = 0; j < i; j++) { + val = -1; + ASSERT_OK(bpf_map_lookup_elem(fds[j], &sk, &val), + "lookup"); + ASSERT_EQ(val, j, "value"); + } + } +out: + if (sk >= 0) + close(sk); + while (n--) + close(fds[n]); + btf__free(btf); +} -- 2.53.1-Meta