Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp278534lqb; Tue, 28 May 2024 15:36:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXBvdzEfSb2oYjYUVGLcNJvZWZpaYL2J+Qs5+4fp9dL42fVi3KPmBOr1zmQO1c1QCTpFf/1eJZV5an6H349kGtOLEM6lBK38Ebs2FpIvA== X-Google-Smtp-Source: AGHT+IFnGpcVdANyrSrh4tkEr/cKVhBceD7QI0O4XWaLI8dwjEKh7nwn85UrGygieWEqxjrwBSD5 X-Received: by 2002:a17:903:2cf:b0:1f4:525c:4c12 with SMTP id d9443c01a7336-1f4525c4e21mr159348925ad.43.1716935817229; Tue, 28 May 2024 15:36:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716935817; cv=pass; d=google.com; s=arc-20160816; b=PgA9rfSvyvZ7dp+wldXekAtZukLl77a4ReeBrMJwO4iCztjDc1tofYDNoCB4yf/2Zl zO2tJoPYrt3RlH2crAX1q/yfVR7ANzUnNC9xIqB0Do35JgvqNapL5OIhPBaYc+zA44TG tExv8RfeQUruMkS+gdovlNI+TnjPruci+T7JACjPJyoIWPDZSXfKuONJkfnoPrfauyHG 8wQQWJ+2FY5BINZPGO4R1V6CSeSmWBOgcC58JF7Z1xmFfNcZCJo6/vhkM+5mo18tVFB2 U1H6fBArVrl3Zu+q5Fg74vjmMeP2IbN/n0vmlA7huTkm/pMHHkIuQAKgm7fZk+lwWy4R r/0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=dZBZ4y8urdzf1j20R0DNA9h5LreYrsyUJmbr0zML8q8=; fh=LAra1JITJF+4gE4rB7ootKcRTpVa9lUVtVxrjHLHTrE=; b=NxtONB+8z54oiY5/HAjl8RovvTnreG3XDpA0SxNdooSW5wnL8dBiVC5q4AlZfs8oXM V43hjXxHJIhzETBvUFaJhSWJ6mbRwy88ZIaINHl2w4gGzMqKJZzO+9VVbCfPE2WOWZs8 IhEyJt1K+1h37XgPd/z9CI7CjR8adb2lbwM4iuRaonhqt3bRvR1Vqq1533qlWHM2bojW qIbM6e7Av3epNso4Yy+KliBRzwPV+Mq7s3XseL9Z2cA/eLgeOail1Io75KxkiqP9x8nB dAjWD0dgaxj73dWKCV6lJH59B5V2T2Utl4pYBD8YJjsbqVtdKQPyhBGhpDsRoq0Sh/rz CRZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oYNQRc2m; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-193185-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193185-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c785cf7si85771015ad.66.2024.05.28.15.36.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 15:36:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193185-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=@kernel.org header.s=k20201202 header.b=oYNQRc2m; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-193185-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193185-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 27C3E282B8B for ; Tue, 28 May 2024 22:36:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4875913E051; Tue, 28 May 2024 22:36:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oYNQRc2m" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 70D6D13D8A2; Tue, 28 May 2024 22:36:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716935805; cv=none; b=ayshP10C34f85CiP7YXPsnF04ThhhFYVXrQmnZaVeSE6v3Tt+n0Yq2nWBmUMaaYQHwZ/0A6NUVMayQwy96ZSs6xJy1KdT5Hv311Elb3w2OygZ/jik3xnttNDvHtTrpxGGB6SMls6mNgvSMeIz4g4VtTszcmkBq5Y+Z+EJY2+tbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716935805; c=relaxed/simple; bh=3gdE/E0U3clBk6Jp0GUhaEaCZOEY/6pMB88YdJtj9tQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GBVbwsTS3Rrvp0f+NfVqVlG/KdRfvEHXjaxhXl9v/7VU8vbfy8SPUcJZiRCi6emccQFCLIIQ9S6ToE1KeDWvKEFLIvFHh6sLXRHL7btidrQDXOvsazSfxMyEpFN/sMKC3FtkMQ8WqHf6vw2vgI/DV3gOMQYFmDoHEVY3dSS+m3o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oYNQRc2m; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 577C2C32781; Tue, 28 May 2024 22:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716935804; bh=3gdE/E0U3clBk6Jp0GUhaEaCZOEY/6pMB88YdJtj9tQ=; h=From:To:Cc:Subject:Date:From; b=oYNQRc2mUDbMRiEVX/3WzyEHrXI/IslbIEWbB1RRoCBpSx2gdnPi/VJat0le/vVuN Aa/KVAEEIvsO8rkdgTRNP96XxAzv5QmYgWLTtnwDnDtn8fm5HbRPA76sWmgYHKBE3q 41Er7hgclneNsdv2BrRQTR8u1r7fYd+/jgCQ5pr9MN08TWkqXH0wFTamKprTq3bsDp m3sdgY1vq+BwflauNKmazylhx+Pvi96jimE3Zs9Yx9KzPpBCYokXfRex/XMhgzN1+b EJfZrjJWBjGRB5roZJbM920KTBkD9etHotvcLeZPhT42vSVT8ffyjSYIz7cML7BhCz mPn+WyFF6sBZg== From: Namhyung Kim To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , LKML , bpf@vger.kernel.org, Aleksei Shchekotikhin , Nilay Vaish Subject: [PATCH] bpf: Allocate bpf_event_entry with node info Date: Tue, 28 May 2024 15:36:43 -0700 Message-ID: <20240528223643.1166776-1-namhyung@kernel.org> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit It was reported that accessing perf_event map entry caused pretty high LLC misses in get_map_perf_counter(). As reading perf_event is allowed for the local CPU only, I think we can use the target CPU of the event as hint for the allocation like in perf_event_alloc() so that the event and the entry can be in the same node at least. Reported-by: Aleksei Shchekotikhin Reported-by: Nilay Vaish Signed-off-by: Namhyung Kim --- kernel/bpf/arraymap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index feabc0193852..3f7718c261d7 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c @@ -1194,10 +1194,15 @@ static struct bpf_event_entry *bpf_event_entry_gen(struct file *perf_file, struct file *map_file) { struct bpf_event_entry *ee; + struct perf_event *event = perf_file->private_data; + int node = -1; - ee = kzalloc(sizeof(*ee), GFP_KERNEL); + if (event->cpu >= 0) + node = cpu_to_node(cpu); + + ee = kzalloc_node(sizeof(*ee), GFP_KERNEL, node); if (ee) { - ee->event = perf_file->private_data; + ee->event = event; ee->perf_file = perf_file; ee->map_file = map_file; } -- 2.45.1.288.g0e0cd299f1-goog