Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp767861lqb; Wed, 29 May 2024 09:54:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3WYPGkgipVz255qlXOtFPh8U8ldf9ToCKcWYWe01AXpK1fPRyXrXkWt5WMCxwZyf56XvKttZaD+Aq2VshHVtR9YWBke8xiEA2Vw3kxw== X-Google-Smtp-Source: AGHT+IHN9Z94D1SUggYW8gtSkJWtGCAZ1mu6bybGegvgitSt7rAKQReCiXJJ1YvkXUdaSNj4vZTY X-Received: by 2002:a05:6a20:de91:b0:1af:cecb:b64a with SMTP id adf61e73a8af0-1b212cf0063mr14358119637.9.1717001676047; Wed, 29 May 2024 09:54:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717001676; cv=pass; d=google.com; s=arc-20160816; b=UuMJ+sq/BGa4UGZwtrDpVMc504e4mqsFSTMnAAAFiFq0AyAAnA5AXcOaFx+taHM628 ONne9Szo4XHmm/Ys4IpG3+2DUKOljhEheQcPiwFCxeMEgOWi8EKNg6c3ZTSTI/mVpEfS 6PJDLS1dBwx4ZGQxCMzR1S2pHET16OAxJp7TClek/1yXZv/kc3+deYnwHcd7sPEhffLQ ArxcyBgL9nwCEcpkoS87ZfCbvH3yImq4ujvkEUH0GTbn4l5TAD+ZsBwMr6Xf7tLMno4f CY3nRQLjU5drlHZm6FT6tFmWU4lLFbh+/dp0HSNbvGXvc/HGAEzyRSnTmGVuqyvq6twZ +YZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=KWI2NSpe+7WLerE4yFBKsFEJGp0TLAv3d84f3/3z3NA=; fh=P+FF9/iwaMp4t/6IruNxWroAykQTGujgzcF11Pv7QKc=; b=uo/CQRqqkEd389givHrrMemHsRX/ScBgdVse80OUrQRDHOQXRe0p7NKgH6kLS1Wgz2 hGiRedLy5h/ihtLqp73XEhE/QaF1z3urvOsp890gyJz88vkoQVa5hK93zM8W9yNPQOqo iqerEYo0ASAO3+ruIK7UDUPQlDJ3L/fhP1iEhtaP6LStdMO7kQQrLV/FV+UIvwUjItW1 UdOazV2sG5j7m67VVCPBqkNjFWt380F0jpWTVEx9WB/Wo3dWrEtGtxZ4N+VOvpCPDjsT uhceLbz48j9gMXBjaL6hVc+4DdpWZvjZ+5Exop6iegA1z2/Sj1jogiSg+K/lP+NTKx/v lPuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-194493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194493-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6bc734f4937si934331a12.482.2024.05.29.09.54.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 09:54:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-194493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194493-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 AB68D28480B for ; Wed, 29 May 2024 16:54:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F0D4E187334; Wed, 29 May 2024 16:54:26 +0000 (UTC) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35CCC1C6B2; Wed, 29 May 2024 16:54:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717001666; cv=none; b=UlS3OmLxOsggF7z4IuDo1/nbK0nqbeCNAWKRvpG9nGibEFXvK9B/LFAZLed0c2Xi+A+NRHo3izL0Vjg68f/OVz/kJTlWsAV8tIcmLc1cONZLUZnEUMWM4LoqGYPrNhtOF+gd4ErVEdCEp6dT5kejLdN2iGxSniDL8ng0ENTgvwo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717001666; c=relaxed/simple; bh=LAl8vHzfRbppB/pNLfLE/513EmF3jGEalkh5FEUirqg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ZDbCSbUWFX1LAjYVPltKC3BSqQLL1Mtz4FggAtJ9lrmy6WMPMfxwDG+6TqVmLxsFbzMjCQfERhMss3A67RUCMN1x2yh3zD86UYaQC897eMLa40aJHkbYpNdN3s5Opk7D9OaePSlfafJfEBIwQNAp7/Eqdjy9Ua+qe9siwga42Ts= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2bf59381a11so1986457a91.1; Wed, 29 May 2024 09:54:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717001664; x=1717606464; 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=KWI2NSpe+7WLerE4yFBKsFEJGp0TLAv3d84f3/3z3NA=; b=SU7aaCp5oHVgzxCBIgBR8wOi35ro2RItX5fsNkckcLwhr1k2B4LunKWTxnzuJOgwrg 4LdTDhlMtggUlUSnldyRDRKehF/Z8/QHta7RGpPMUvQMB5OLIO2/0oJ78dkzgVRforlC sBHQdLRdKIg1buFUdXkKbxcVucuxL1gKKFqXvmmeDFpaYQoMNYwwzCKxDNPPG69IawAR sP0g9Jm8fCV4IcUw8pl3bnoA1uMa4FzVkjsV0ltEhKnq49QI/9XM/xDo00LJZ3MQihX2 ig6gkgMUZc149uswIjgbmGz+OAdHWfBeBEv3YVrt3jPcdwUXQgm2FI+VB06hl0sAYpje pYsw== X-Forwarded-Encrypted: i=1; AJvYcCXf2A/I0PfRfz+j4PbSGwhJI7J0iJ9rPWSBfAgJviHjMYCl2o9QzSmtlMdg+1H4p3+v2N70QgXOgSo9MpI9bDLnLEEH6YQai8fmPAKlVSLueW2lYSLZ6wyQvjdeqq9TykwL X-Gm-Message-State: AOJu0Yyt3S036nUYAavFH5Dedw1PzueAfAQ3cyCo9zlrtgaSAezZsi/R sncCHrZYLOQ7UUQD8CaxOCp7ePlc0A5K1O+bzMwVXGg+imwNSHu8T8xY4gYXigyal8hLLUdybw+ T/ecH0x5cjQScSX3YjFO+VGY1PfY= X-Received: by 2002:a17:90a:a409:b0:2bf:9981:e0bc with SMTP id 98e67ed59e1d1-2bf9981e16fmr9700999a91.27.1717001664337; Wed, 29 May 2024 09:54:24 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240529065311.1218230-1-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Wed, 29 May 2024 09:54:11 -0700 Message-ID: Subject: Re: [PATCH v2] bpf: Allocate bpf_event_entry with node info To: Jiri Olsa Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , LKML , bpf@vger.kernel.org, Aleksei Shchekotikhin , Nilay Vaish Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Jiri, On Wed, May 29, 2024 at 1:31=E2=80=AFAM Jiri Olsa wrot= e: > > On Tue, May 28, 2024 at 11:53:11PM -0700, Namhyung Kim wrote: > > 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. > > looks good, is there any profile to prove the gain? No, at this point. I'm not sure if it'd help LLC hit ratio but I think it should improve the memory latency. Thanks, Namhyung > > > > > 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 =3D perf_file->private_data; > > + int node =3D -1; > > > > - ee =3D kzalloc(sizeof(*ee), GFP_KERNEL); > > +#ifdef CONFIG_PERF_EVENTS > > + if (event->cpu >=3D 0) > > + node =3D cpu_to_node(event->cpu); > > +#endif > > + > > + ee =3D kzalloc_node(sizeof(*ee), GFP_KERNEL, node); > > if (ee) { > > - ee->event =3D perf_file->private_data; > > + ee->event =3D event; > > ee->perf_file =3D perf_file; > > ee->map_file =3D map_file; > > } > > -- > > 2.45.1.288.g0e0cd299f1-goog > >