Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1674991pxj; Wed, 19 May 2021 11:11:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGAl4bWRoQtV0PCtXlpnEd9CFKnBccf3TXaxm3KdRovXVaGmiTSl0VMthlnlkPXKtUC8z3 X-Received: by 2002:a05:6e02:4af:: with SMTP id e15mr244436ils.131.1621447880260; Wed, 19 May 2021 11:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621447880; cv=none; d=google.com; s=arc-20160816; b=Nbsi4rGa7oqcJtbO2oN5ocxI0qgcdxEEeHekNOUX4pJAKbdQcaHWGOerIt6BoLocUl JytrryFjBNAZT/jvcYRByBYpMLocvXrfRc0ge6m8mXNgvzRhEXI/EK02IFjGZZuY0AUu DnLN4A2mTqqZHZlVNl6ZckDIJ5JPxYjm+wGCUElME5MHWyFlmUH1N73oik3sYDsTyCOA TNxs6STFvTJ5rGdJsk9OJoVKD/jwPvFAIEk/ey0swhCga4tCxABSO8vkPn/A9TVCu1U4 sa0qgYhCZpWvSyCgQgGDHcs5Kgo5iZOhm42my2eTX9CG4Ik5aaXFhHmhwlxd2NhSUJFc yZxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YPdGuTheVxR4ga139eQKM5TvxRmYiVXY5RnZ9U/3GXY=; b=BxN5r6/Iner9/bEqAX4XIBXuiv0cRUyGfswVKTs2hVpB09e5+i9p3rH3BTQrQxeDlg Hrk7Oii6zo45wiFSHI7d09w7bIaOk1IS6T/6MVanICjdK013mRMf0Xyv5eqsYG60Dzql BcELkQ5MKYmxMe8m/O/jgeblhiFFh2dwCbTT4Co88MVuS/EAkz/lEe0q62qxzka8x73S dJB0C2UzbrOq1seSTnJH1uWyPrC1oAs9BeWc+cDqf59rOI6aXCyhWLAIca5nlufb4A2x WdQLd2bj1FVDvlZwrCPZwtXNHa7Hg1D/Sr8PCTCuTdvK91xdG1A3DjhZb9+I8LiJf9G3 cHPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=D7FcY7n7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si260823ilq.159.2021.05.19.11.11.07; Wed, 19 May 2021 11:11:20 -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; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=D7FcY7n7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349603AbhERNan (ORCPT + 99 others); Tue, 18 May 2021 09:30:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349598AbhERNal (ORCPT ); Tue, 18 May 2021 09:30:41 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE137C061573 for ; Tue, 18 May 2021 06:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=YPdGuTheVxR4ga139eQKM5TvxRmYiVXY5RnZ9U/3GXY=; b=D7FcY7n7zkSyHz9kp0WQgo8XFC CNBzQJKb0u89zPe/WtlV1iriV5HR/n2jmbobo3lvTfNYfzQzmHUZMXmobaZfTBQnEPb6lczq95Stc F9G7oNKpuC0MH46MCCMDwCxAHazTAXqyrlC/ES1O/vC6M9uoy/P2+ZgcNzVi4+5Yux6WHvGAAmGvX D5NfkqfvoigxOsINWvu2PvayLzcwQRdzilC1b8FgLrBnfvYsKcSipMGsnmVhSYyacfmpNin6iotAu Qtjn78t485FqtmqcO8vD7+/TJQasiNBEnuLTooHaSOGTCgaY4V9Y5eidHwRKoNGJzG5B5i+pK3+NN 06UUoWNQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lizmZ-000skL-HY; Tue, 18 May 2021 13:29:11 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 807D3300250; Tue, 18 May 2021 15:29:10 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 711923011B173; Tue, 18 May 2021 15:29:10 +0200 (CEST) Date: Tue, 18 May 2021 15:29:10 +0200 From: Peter Zijlstra To: Like Xu Cc: Kan Liang , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, Borislav Petkov , seanjc@google.com, x86@kernel.org Subject: Re: [PATCH v2 2/2] perf/x86/lbr: Move cpuc->lbr_xsave allocation out of sleeping region Message-ID: References: <20210430052247.3079672-1-like.xu@linux.intel.com> <20210430052247.3079672-2-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 18, 2021 at 08:34:33PM +0800, Like Xu wrote: > > > + if (!static_cpu_has(X86_FEATURE_ARCH_LBR)) > > > + return; > > > + > > > + for_each_possible_cpu(cpu) { > > > + cpuc = per_cpu_ptr(&cpu_hw_events, cpu); > > > + kmem_cache = x86_get_pmu(cpu)->task_ctx_cache; > > > + if (kmem_cache && !cpuc->lbr_xsave && !event->attr.precise_ip) > > > + cpuc->lbr_xsave = > > > + kmem_cache_alloc_node(kmem_cache, GFP_KERNEL, > > > + cpu_to_node(cpu)); > > > > (coding style fail) > > > > But then I looked at this function, and srlsy that !precise_ip is the > > only thing you need @event for? Why do we care? > > Kan once commented, we only need to alloc the buffer for the non-PEBS > event. It seems the check "(cpuc->lbr_users != cpuc->lbr_pebs_users)" > is implicitly removed. > > I think we still need to check !precision_ip, right ? It's just a memory allocation; who cares if we allocate but not use it ever?