Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp452200lqb; Tue, 28 May 2024 23:53:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX9sp7WPdjw+3OCdqGFW56d05k3FM8E/zbplJy0CluHN90gY1lh48T12LlQ3TmA0EwR5hz4hrHxR0SKioadfrPbaAknxPLv2hO3wgrneg== X-Google-Smtp-Source: AGHT+IH1GpFq+EnlfLEVPiHKFHABnx02y2r97E7dFQEOhloL80qHVDp3wXkR+ii1+Z5t98HOnx9p X-Received: by 2002:a05:6870:63a5:b0:24c:b92e:a130 with SMTP id 586e51a60fabf-24cb92eae0emr14221766fac.15.1716965601285; Tue, 28 May 2024 23:53:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716965601; cv=pass; d=google.com; s=arc-20160816; b=VE0qzs7GP1wnGW4KOwmzRCPo+rXmtUsh0MxzSbjRuyEYPvIV3fd++V8yQxTmZ75iUg qgl+PkS/JhmaiIMM2zFKaH06n1NRXCflGjwZX84kttTB8g/bMhAY80Y1menw0I1rbVbE hlqvNPnePLKtqLkZEoh6yl7otagtEC+1DgRNzrXn6YAg+xse8fzId/MU49CgMp8+M2oU Wz5lsMTZjBEstU7PimM6GkCurheRdwaYEnsPYK+0IdUnZjxwhw1gV0lx+kRc/sp3/7xC S93Afv+rf6Nxezqjnr9DgUhB9OL9Sj0krMS91AYt/0HRcZwzIBgEEgw404Ex56a08vZ0 zkiA== 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=rLi1D2RuYrrwV5IuYH6e/Kkfun2iOGUQGknNOn8gvYg=; fh=LAra1JITJF+4gE4rB7ootKcRTpVa9lUVtVxrjHLHTrE=; b=XsnJftOnq6i/6r+0YU5Oc28rJTenuU043SnGOGsaFTEEkj4VFv6OrpS7yeVHXypa7u q6b0SA/Eq/qtkgk4CAToUucasfM9ArODcxHLcRyq3kZoVxFouX54PvkbSn7KTMdVe0Mq mQzmSL8Vn9mIM7SF2HCJlG6S/AbYmC6X45rkhIP0vomPvcW//mruS0QbMsI6bLV7b698 rWeJvuNia23BgVN4YcO5Q1TiCIrWKTdh0hxpIFDHFNeDJk5uOs3Ln4yjX+xoNLGt+Hmy LArv+VCMnbxX/u4oVXlZt/h1/8qncmq1sCVrPAaolxrT3S4nOKICNaV+Td7iWT1/+cAS o83A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WF9i2rk5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-193548-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193548-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 d2e1a72fcca58-6f8fd4d3230si9540517b3a.257.2024.05.28.23.53.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 23:53:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193548-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=WF9i2rk5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-193548-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193548-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 E5036289F6F for ; Wed, 29 May 2024 06:53:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8253160862; Wed, 29 May 2024 06:53:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WF9i2rk5" 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 DF924273DC; Wed, 29 May 2024 06:53:12 +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=1716965593; cv=none; b=BKAf0gTK+DQrDbP6FxaJ17FLbc9KsuoOQnF/FhNXt+cNHlw+5FAkWUbuHKBLBOFlno4s91YysTp481Aaqgk5ekoxv082vg8Xh2AMy/XfhXI34FiX8T3wrpiRwRya+MYdO15cZ/hOlMP5G4QNKKR2t/DsCDx/LWvZo3qsz4FMr4g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716965593; c=relaxed/simple; bh=xbZlbav7dXHrx2F3xU5CD97U7cRldlN43gsuFjbcUtY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=thn45sWY+0FVUb/JBYwi8AyJsvn91dW5vFRvvHZDB846FeM/DdnE+sPdsoGsVaYGXU60Xp6g16ngs/px4kIZhYnNfG0YwSgFjB3HtMplTgk//4Bzgp77Up2rOakvKKCsPYC6O60bqfSf1nziLLLT7JRp4njckq1vBRZsE0qjbVg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WF9i2rk5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAD57C2BD10; Wed, 29 May 2024 06:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716965592; bh=xbZlbav7dXHrx2F3xU5CD97U7cRldlN43gsuFjbcUtY=; h=From:To:Cc:Subject:Date:From; b=WF9i2rk5u5QpRo4zY2eI4DMJ+pgmfzFs74eUgo/KWWndVfkd3Kv7X2FMvG0SwuJiN jtROgPPFpzG2ONLOefi49R3xMrRaR0ILp1ev9q7yc7i/M4wvbERDp3OeTdAps0wmyp qzPzinWyFZ2ycPJxIk6AOH9gzlQYu3Fme+58v3ROPQefH/erz0BjnKxI8mmIs6xQVA NSHvTp3jMG4Ep4i4+mcDH2gKI3viiuRx3iZFSN6jA07kM2xyDQWHO9Py4pjf00McxZ 5fX5micaCP07h0C8e9Jj5bQ3yCRo7bgTCEMu5Shu90wwfp4s661vrAptfhoJ8DAf8G Y/7/k5Zc2tZ7Q== 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 v2] bpf: Allocate bpf_event_entry with node info Date: Tue, 28 May 2024 23:53:11 -0700 Message-ID: <20240529065311.1218230-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 --- v2) fix build errors kernel/bpf/arraymap.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index feabc0193852..067f7cf27042 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c @@ -1194,10 +1194,17 @@ 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); +#ifdef CONFIG_PERF_EVENTS + if (event->cpu >= 0) + node = cpu_to_node(event->cpu); +#endif + + 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