Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1736610ybg; Sat, 19 Oct 2019 01:23:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyA+NPVi+VI9JD1XcnZmAK1FCDlu600lmSBkSoveHZrmeBTgZDLGTO5aiCJE4jkAM71DVkh X-Received: by 2002:a17:906:6087:: with SMTP id t7mr12598181ejj.58.1571473431448; Sat, 19 Oct 2019 01:23:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571473431; cv=none; d=google.com; s=arc-20160816; b=yt9B+ezLP0KuGUxN2+z5FhM4/uLwFfzauicer4d33w+ad122NIiEbUhflM5nfJh8JH c6gymGqt7A0S+OQ5H5rMtMw1GJbXVTWw1eNXxuUjMn3CRT5hoiRElq9Sde5z5x/63FYG 3lk/lQF08qt/O+gEiJDYWTmtDNpoEhsTzg/NKnyAIFFzwmNerkoABbCMM1Sev/WwfdlT MkXC8zj1fTDhEY6iDylGwxNWCNBc1bP+ncF8bDnVbWOpavYVpOuAXwBweidoN7D+fvA3 PL/vyP7CtXk1OCjUjYd3uf2l+QAMFj9L5AAU1Xf+W8MJR7wFnGp7Cwv2r0YvoG/kwobM AQuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=8Jfb0ORT2lb4mdBxDw76VdU4kqZYkxFdT1iHLR94sfg=; b=jdNaOo0T/V7pL5tVFx933QTty+HYuCBumdHeHwFLUPQjsEXLP0Gwm2k3JexdEY1V7l SSyTMcj8PKZkX3FQ51vvSFWv6U3i4z+h+/GO5sktaCuLEeZq9Yl8UNuYVA/iuepXxX5g m5nlaNW7rkYP3wuMndc+pXCmeuJ+uveXBvwEzsg07rCeZWjfwX8cMdJ+qUTOaXMahTJ9 FAoo/yE7ToM5B7sI12VJR9fjiaGvxUa0kD4xm9Qs2VOElEEsLhiQIYCJFq6apSuqztWK FmIDA5VlUqPoJ+ioyav9dBfvHV5s3Qr6xGdhiDIHygjnuVj8vpRoTb6jLeDe6VS1rVR9 v91g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m12si5546491edc.50.2019.10.19.01.23.28; Sat, 19 Oct 2019 01:23:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2633954AbfJRMs0 (ORCPT + 99 others); Fri, 18 Oct 2019 08:48:26 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:56769 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2633907AbfJRMsY (ORCPT ); Fri, 18 Oct 2019 08:48:24 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iLRfu-00075o-4O; Fri, 18 Oct 2019 14:48:10 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id A5A981C009C; Fri, 18 Oct 2019 14:48:09 +0200 (CEST) Date: Fri, 18 Oct 2019 12:48:09 -0000 From: "tip-bot2 for Yunfeng Ye" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/ring_buffer: Matching the memory allocate and free, in rb_alloc() Cc: Yunfeng Ye , "Peter Zijlstra (Intel)" , , , , , , , Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <575c7e8c-90c7-4e3a-b41d-f894d8cdbd7f@huawei.com> References: <575c7e8c-90c7-4e3a-b41d-f894d8cdbd7f@huawei.com> MIME-Version: 1.0 Message-ID: <157140288949.29376.10061367480857136332.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: d7e78706e43107fa269fe34b1a69e653f5ec9f2c Gitweb: https://git.kernel.org/tip/d7e78706e43107fa269fe34b1a69e653f5ec9f2c Author: Yunfeng Ye AuthorDate: Mon, 14 Oct 2019 16:15:57 +08:00 Committer: Peter Zijlstra CommitterDate: Thu, 17 Oct 2019 21:31:55 +02:00 perf/ring_buffer: Matching the memory allocate and free, in rb_alloc() Currently perf_mmap_alloc_page() is used to allocate memory in rb_alloc(), but using free_page() to free memory in the failure path. It's better to use perf_mmap_free_page() instead. Signed-off-by: Yunfeng Ye Signed-off-by: Peter Zijlstra (Intel) Cc: Cc: Cc: Cc: Cc: Cc: Link: https://lkml.kernel.org/r/575c7e8c-90c7-4e3a-b41d-f894d8cdbd7f@huawei.com --- kernel/events/ring_buffer.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index abc145c..246c83a 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -754,6 +754,14 @@ static void *perf_mmap_alloc_page(int cpu) return page_address(page); } +static void perf_mmap_free_page(void *addr) +{ + struct page *page = virt_to_page(addr); + + page->mapping = NULL; + __free_page(page); +} + struct ring_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags) { struct ring_buffer *rb; @@ -788,9 +796,9 @@ struct ring_buffer *rb_alloc(int nr_pages, long watermark, int cpu, int flags) fail_data_pages: for (i--; i >= 0; i--) - free_page((unsigned long)rb->data_pages[i]); + perf_mmap_free_page(rb->data_pages[i]); - free_page((unsigned long)rb->user_page); + perf_mmap_free_page(rb->user_page); fail_user_page: kfree(rb); @@ -799,14 +807,6 @@ fail: return NULL; } -static void perf_mmap_free_page(void *addr) -{ - struct page *page = virt_to_page(addr); - - page->mapping = NULL; - __free_page(page); -} - void rb_free(struct ring_buffer *rb) { int i;