Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2708025rdb; Mon, 5 Feb 2024 15:28:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvJ8fyFZjkQ/B95Y9XctbIZq2saKJ+Xpc3kh3LPUmLLYAt3DL0i0Pe5rWNNY6uqEy1FO6v X-Received: by 2002:a05:6358:714:b0:178:b97c:f087 with SMTP id e20-20020a056358071400b00178b97cf087mr472811rwj.15.1707175737289; Mon, 05 Feb 2024 15:28:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707175737; cv=pass; d=google.com; s=arc-20160816; b=EmV9YgptwaJzE56hWFtz9qVu1SgRQmQvotT4VnblYtyDkOfh0buNJeNh3GaNvza/nj HjjKWv9/nw+FZPWQngmGtBbX9xJg+fjFaSb+5CWcyD+l2j6Soustuz6NMrD0GVYrxTB7 SPPCiM0tkemuQqZJ0ABpyHmqksM3jh7QgxgIFk+3dsgYS+WgXMFUr3GhskIjs/aZo0s6 cIStfFjiQx9pcc1roUrvbiEwJI2yqynppnyot+pJmjQL0Qd+9rRJGl5TrMghQbDcmaaL 6lfiUJVVOXAX3NvXtnr/wuXF6ZCJFiITGxxQ3sqT5/BvJH1N2PuXrsA1b0YOVzrDCYmH mGIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=3W4biwjTNLI62PNfsqhj18Fa+p++jpbdxldJj1IjrJQ=; fh=n1aQSkVlqsFAipdc5CgCTnZNT1+Rub/Z2ezZ8H8vvuc=; b=kfowkC33mpcTIiD/jDdYMQcxE/QWvy86UA48weXg4XGvPbaEkuap0gc91shJ3nIE11 qat0sSsPsA7rDgwI7uFtMRcIigN9aanWoi0VcYLgU+uS+192MDcW7pgxsPm5c0awnfdG EmJ3dCnK3fl0YavKytaIXMXbKLSy2V7wTBVKqhtebNZ9Y+ZH+TuvAtskEQcFsF32dL3t aqdBEZtbvO4D2Rt2/GqI4lLGb5dpQxWP1XGNNdbfsmYL5ck5i0FKvfoulZr5GopOKlMs 0mvxS/A5ttCYkxxyJBOVHjCkjOrUiRdjQGrJkjAlTcHo/oni/pun4zq/2QZNdDHBsYIt CJVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=JxEzh6tp; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-54081-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54081-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=1; AJvYcCWgmHaJXWbANe/ygnnb4TYArYMJbmtvuGoffYFpGtSvGXlW7HB4KT/ZnQgoJz9qn2+HCIwDkJqm1/ILOFICN8blyMSZUFXqZE01M4viXA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e12-20020a631e0c000000b005dbec91be93si566848pge.595.2024.02.05.15.28.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 15:28:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54081-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=JxEzh6tp; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-54081-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54081-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7C76328DBE7 for ; Mon, 5 Feb 2024 23:25:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 034E648CD1; Mon, 5 Feb 2024 23:24:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="JxEzh6tp" Received: from out-176.mta0.migadu.com (out-176.mta0.migadu.com [91.218.175.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E304E4BA8D for ; Mon, 5 Feb 2024 23:24:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707175498; cv=none; b=s7xQFGaN2whS1I/ALPUqPr8isEBVzz2SmFJCiZHfJd6XocIstyvBx5srGKfkBplCTpOwE3+NTtFWInZANJx6rD0Y8ugp3gfFQoeeJjt8r3hifGUaypyfHRJY1KrbP1xOgAY7g2eNvcfu7T0wsQLY6KaKmNud0q1rcsHLu2FTQps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707175498; c=relaxed/simple; bh=y3Ra/aPyXFejjmK6Gi4QOmq1Gn2dv0Xmng3txeAbyng=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=SxtKZYbv0YGuyoJgNSju9mw4Y6H/9qDItQzcbK67BKgbm4H3+4Wrh0dwVQ42efah66OKXaSn3+S9W8bIophVCBTkIZodEHSuxw3aBLMJFn20AKjNNFpNvcLvTYeJ04YE/IglS8Nyc3UC6Q6c/X3snurb7eiNQ5IatJnSSvJL7uk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=JxEzh6tp; arc=none smtp.client-ip=91.218.175.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: <5a08032b-ed4d-4429-b0a9-2736689d8c33@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707175493; 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=3W4biwjTNLI62PNfsqhj18Fa+p++jpbdxldJj1IjrJQ=; b=JxEzh6tpnpG+Wmmxm3eutJ7ZLIMRxeUtZKBc+mwSXTZiRstt6qXrSpIIbQIVzYdiF/YnL7 Z4yBFsoe1OKLa4WFhr7zQPD4kWanQfawljUFMNAwoxvvErE3I/Y3oL2nOhyPJSmxUlTjA2 2vmhaoi5RPEdN9EiEC1V/WdYUTsOAiQ= Date: Mon, 5 Feb 2024 15:24:43 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] bpf: Separate bpf_local_storage_lookup() fast and slow paths Content-Language: en-US To: Marco Elver Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org References: <20240131141858.1149719-1-elver@google.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 2/5/24 7:00 AM, Marco Elver wrote: > On Wed, 31 Jan 2024 at 20:52, Martin KaFai Lau wrote: > [...] >>> | num_maps: 1000 >>> | local_storage cache sequential get: >>> | | >>> | hits throughput: 0.357 ± 0.005 M ops/s | 0.325 ± 0.005 M ops/s (-9.0%) >>> | hits latency: 2803.738 ns/op | 3076.923 ns/op (+9.7%) >> >> Is it understood why the slow down here? The same goes for the "num_maps: 32" >> case above but not as bad as here. > > It turned out that there's a real slowdown due to the outlined > slowpath. If I inline everything except for inserting the entry into > the cache (cacheit_lockit codepath is still outlined), the results > look much better even for the case where it always misses the cache. > > [...] >>> diff --git a/tools/testing/selftests/bpf/progs/cgrp_ls_recursion.c b/tools/testing/selftests/bpf/progs/cgrp_ls_recursion.c >>> index a043d8fefdac..9895087a9235 100644 >>> --- a/tools/testing/selftests/bpf/progs/cgrp_ls_recursion.c >>> +++ b/tools/testing/selftests/bpf/progs/cgrp_ls_recursion.c >>> @@ -21,7 +21,7 @@ struct { >>> __type(value, long); >>> } map_b SEC(".maps"); >>> >>> -SEC("fentry/bpf_local_storage_lookup") >>> +SEC("fentry/bpf_local_storage_lookup_slowpath") >> >> The selftest is trying to catch recursion. The change here cannot test the same >> thing because the slowpath will never be hit in the test_progs. I don't have a >> better idea for now also. > > Trying to prepare a v2, and for the test, the only option I see is to > introduce a tracepoint ("bpf_local_storage_lookup"). If unused, should > be a no-op due to static branch. > > Or can you suggest different functions to hook to for the recursion test? I don't prefer to add another tracepoint for the selftest. The test in "SEC("fentry/bpf_local_storage_lookup")" is testing that the initial bpf_local_storage_lookup() should work and the immediate recurred bpf_task_storage_delete() will fail. Depends on how the new slow path function will look like in v2. The test can probably be made to go through the slow path, e.g. by creating a lot of task storage maps before triggering the lookup.