Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp761397pxf; Wed, 24 Mar 2021 15:35:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRnuf9FpDe9j0sjh+zHDrspiM/hX0KuhtAhE9webblORcNI9h7Py7elHAqDjskT0Bkw82v X-Received: by 2002:a17:906:1985:: with SMTP id g5mr6015375ejd.285.1616625340578; Wed, 24 Mar 2021 15:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616625340; cv=none; d=google.com; s=arc-20160816; b=gYBFah1feXlET+tjup6Pb1qQpI9cSIc9XRYxFGsbx3yFDa+8AK96NwQawjA+GKWMdP P0dmJCEaF87VyAhpqu5O1GlQsVUzIyKf17lxt+nUu38BpGNp1h8CVQtkHImYddV46zJj beNsNAFo9g4NxOuqFTXX5m66tHWlvw5EQgBDqR+HnEnZC7GqWqFT8tzQUyV6FcY7BVqu kWyiQcNXR9QjQ8/tzyPtuyVoxFzLU4BKarsEMMn8/c7NBz9mtn2AlXLXQJQRNl0+oe7M MtS6/AHoPReim1r0eVsmEBx0l1lNeivxP9iKfY+VdFSLfc6TKOUN5nKRpjh57qirxslE /42A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=2bhVQeu9eTo+5YCCJg+gsP5YZSTsTZpoMQWL8vU5sIA=; b=IOnGVCD12+PBfFOGO77cigj7adkI5/gux06wb43LET/SXHhb1VNj3tNTyni9phPSz6 IKZrRbv2eaaTtF44QtU10hrTUF8iMKyiUzKGOWSF/ixgDFAe1CeGz4g6EkTqm1BgdDEi lRW05FhLQUdbZL587nBahye6s+xaGvhFLX/8NIDojM3IMpXyr4z9IIsmxmX2Rr9JUMFh s+fvw41xc8ONn8TVX5mLU8S4cUi0v7IHgzthFGN7P7lKOEdcicaj2y1tiUnSRH+/GkKi g+fQAlSbtR3WY06sbZBRuczvc6ws8hj7SRZQ0Rn4ZPw7IgityaApTdTBWp9o5WMvZAiI La8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si2708031edv.534.2021.03.24.15.35.17; Wed, 24 Mar 2021 15:35:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233073AbhCXFnC (ORCPT + 99 others); Wed, 24 Mar 2021 01:43:02 -0400 Received: from mga12.intel.com ([192.55.52.136]:61502 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232805AbhCXFmd (ORCPT ); Wed, 24 Mar 2021 01:42:33 -0400 IronPort-SDR: H3BAL5/2LxDdOeN09prRVJ6Rosb0x2i82ghu1ghYyToL3UzkhuIjKUfIyibK7S9Lw7/qH9990w Kfco45hOP6CQ== X-IronPort-AV: E=McAfee;i="6000,8403,9932"; a="169972015" X-IronPort-AV: E=Sophos;i="5.81,272,1610438400"; d="scan'208";a="169972015" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2021 22:42:31 -0700 IronPort-SDR: uY8zEC9EPsgGJ7D6e5j4Zix4CcoOOaky9/lPtfzMmfm1SD2SJ/ltKADe5SflKld3bHpzQ0M5f6 uEXMt3ar5jqg== X-IronPort-AV: E=Sophos;i="5.81,272,1610438400"; d="scan'208";a="514059073" Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.238.4.93]) ([10.238.4.93]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2021 22:42:27 -0700 Subject: Re: [PATCH v4 RESEND 3/5] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region To: Namhyung Kim Cc: Kan Liang , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Thomas Gleixner , Borislav Petkov , x86@kernel.org, linux-kernel References: <20210322060635.821531-1-like.xu@linux.intel.com> <20210322060635.821531-4-like.xu@linux.intel.com> <5fda3599-1b51-5f58-fdcc-2afcf6d4968b@linux.intel.com> From: Like Xu Organization: Intel OTC Message-ID: <103ad691-4ea8-6fcb-afcc-c69e3abcd1f6@linux.intel.com> Date: Wed, 24 Mar 2021 13:42:24 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/3/24 12:04, Namhyung Kim wrote: > On Wed, Mar 24, 2021 at 12:47 PM Like Xu wrote: >> >> Hi Namhyung, >> >> On 2021/3/24 9:32, Namhyung Kim wrote: >>> Hello, >>> >>> On Mon, Mar 22, 2021 at 3:14 PM Like Xu wrote: >>>> +void reserve_lbr_buffers(struct perf_event *event) >>>> +{ >>>> + struct kmem_cache *kmem_cache = x86_get_pmu()->task_ctx_cache; >>>> + struct cpu_hw_events *cpuc; >>>> + int cpu; >>>> + >>>> + if (!static_cpu_has(X86_FEATURE_ARCH_LBR)) >>>> + return; >>>> + >>>> + for_each_possible_cpu(cpu) { >>>> + cpuc = per_cpu_ptr(&cpu_hw_events, cpu); >>>> + if (kmem_cache && !cpuc->lbr_xsave && !event->attr.precise_ip) >>>> + cpuc->lbr_xsave = kmem_cache_alloc(kmem_cache, GFP_KERNEL); >>>> + } >>>> +} >>> >>> I think we should use kmem_cache_alloc_node(). >> >> "kmem_cache_alloc_node - Allocate an object on the specified node" >> >> The reserve_lbr_buffers() is called in __x86_pmu_event_init(). >> When the LBR perf_event is scheduled to another node, it seems >> that we will not call init() and allocate again. >> >> Do you mean use kmem_cache_alloc_node() for each numa_nodes_parsed ? > > I assume cpuc->lbr_xsave will be accessed for that cpu only. > Then it needs to allocate it in the node that cpu belongs to. > Something like below.. > > cpuc->lbr_xsave = kmem_cache_alloc_node(kmem_cache, GFP_KERNEL, > cpu_to_node(cpu)); Thanks, it helps and I will apply it in the next version. > > Thanks, > Namhyung >