Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp754040pxf; Wed, 24 Mar 2021 15:22:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6RgOyG9F+KDQxSPxHU/B/Nw068RC8aPXnFjUUCHilKbHVzKPak+euBuUC7LuQtH1YMfim X-Received: by 2002:a17:907:1692:: with SMTP id hc18mr5989488ejc.265.1616624528574; Wed, 24 Mar 2021 15:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616624528; cv=none; d=google.com; s=arc-20160816; b=pXjXjEhyq8GJExFLoRiQh4BJ+jcIpeoZWphvLP63se8/Zc4twIP/QpTc87GL+kO/BZ 2ndeJW+xnBDTCwVZCL10xQbQKVabFWafQ45pOML4pPHdzOCxxWlymGrpV4pimKmFGfuU nML4xka42XcPdyGqYMIzn4kc5moLNXU65Z8F+HrQlMotDV5ea1bkGHmkjh7eAtvd+qzX sxero6NUlwtx4HB777N1D3dqUm3Usz2GJ26lHiWo/u7UBVGStxsT+Bu4aiYYWTsNbaTe bbZFE2eWobey2nxKwc8gjXQNzbPxdlZp2K7JCfp5oyyOI+PSQzGuPCOMvDR45bm9Fz2d dOYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=TgVU7M3hkTrPRlTPdUuQz41iZtTwxWQCelmHjTb2Nyw=; b=VJLs3nLt9QTRaL23oyjrgn42lEUhJ7gnnsTN/JvatD7cEAJtHZxZooBhLeguj5yCVw L3Xs8UjKD4ZhKZaru4kQq6cM9pb7mmXyR0huhzNqC8sWe5dq+DFXaVkIIoWx/IxyoYCa VaRhyZqtp6+DFcZ1n5IrKVIIDiQkhBYRy/mEDQ8roSuJRptGZ9Uz0m5vUj6JmqR6qE5c 4J6iVnmHoJBnkOyHqmIaIMYXj18FN+tJfp7IdEavoQ6RGDChf3FqZJ/TGMywjMA0Q6CQ 5A8eRvjs1iaFm+78svx2B+GvlPTfMApRVr8RDp9y5l9X99vu1Y5f814dYHnVEjxiy3ro 5ulA== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s5si2810286ejx.287.2021.03.24.15.21.45; Wed, 24 Mar 2021 15:22:08 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229801AbhCXEFX (ORCPT + 99 others); Wed, 24 Mar 2021 00:05:23 -0400 Received: from mail-lj1-f175.google.com ([209.85.208.175]:34664 "EHLO mail-lj1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbhCXEFE (ORCPT ); Wed, 24 Mar 2021 00:05:04 -0400 Received: by mail-lj1-f175.google.com with SMTP id f16so28500524ljm.1 for ; Tue, 23 Mar 2021 21:05:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TgVU7M3hkTrPRlTPdUuQz41iZtTwxWQCelmHjTb2Nyw=; b=MaE7wEj95QcnMpn9kmDpsc97VT4zFdKbIaGqDUCXYZZ9fHFSFtTbbVjLVyA6MABjKl mz8RMldPPVY0Qm9GlBtiakcLtr1Qs3OKOo0SVMIjZOAQMx9qFNHMz+NiRXvbcKhFHmnz gYgHWVTO6N6GrCrvIXTgRjKpregU7WIa+PJ+rJCLZ8mukLb0xkkf0vHzfTGfoZTpjIo/ Bhy19HmOSPZok9LosTGRPjgVPNzp5vG5uU5ou9pY6B88RpkuHv55KSK/0/FMAONDelxx KRBoRvortQR1FYSHeui9W4WkBSIYtSaaahz0eDazHSKGBMdRHv8wzg0zqRCd1zWy9e20 FFoA== X-Gm-Message-State: AOAM531t2CZOQxvjRIcKdcJo9MS1Dx1YbbBGQMsTbJQwJERBL1YXdbvw FGDIfaMBVC68sDcPS62gL4/AyZm8tWn7JEEkJRq7JYh9 X-Received: by 2002:a2e:5057:: with SMTP id v23mr696969ljd.393.1616558703541; Tue, 23 Mar 2021 21:05:03 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <5fda3599-1b51-5f58-fdcc-2afcf6d4968b@linux.intel.com> From: Namhyung Kim Date: Wed, 24 Mar 2021 13:04:52 +0900 Message-ID: Subject: Re: [PATCH v4 RESEND 3/5] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region To: Like Xu 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, Namhyung