From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752203AbdFLNTI (ORCPT ); Mon, 12 Jun 2017 09:19:08 -0400 Received: from cloudserver094114.home.net.pl ([79.96.170.134]:46198 "EHLO cloudserver094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751944AbdFLNTH (ORCPT ); Mon, 12 Jun 2017 09:19:07 -0400 From: "Rafael J. Wysocki" To: Lv Zheng Cc: "Rafael J . Wysocki" , Len Brown , Lv Zheng , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org Subject: Re: [PATCH v4 4/4] ACPI: Fix memory mapping leaks in current sysfs dumpable ACPI tables support Date: Mon, 12 Jun 2017 15:12:01 +0200 Message-ID: <5405056.jcq3epAkXF@aspire.rjw.lan> User-Agent: KMail/4.14.10 (Linux/4.12.0-rc1+; KDE/4.14.9; x86_64; ; ) In-Reply-To: References: <5361b51c7c257b3216475018a3a5cc4f8b6b21c6.1493281247.git.lv.zheng@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday, May 09, 2017 01:57:54 PM Lv Zheng wrote: > This patch adds acpi_put_table() to make all acpi_get_table() clone > invocations balanced for sysfs ACPI table dump code. > > Since Linux does not use all of the tables, this can help to reduce some > usless memory mappings. > > While originally, all tables will be remained to be mapped after a > userspace acpidump execution, potentially causing problem on server > platforms. With the new APIs, it is possible to release such useless table > mappings. > > Signed-off-by: Lv Zheng > --- > drivers/acpi/sysfs.c | 41 +++++++++++++++++++++++++++++++---------- > 1 file changed, 31 insertions(+), 10 deletions(-) > > diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c > index 2bbf722..14425dc 100644 > --- a/drivers/acpi/sysfs.c > +++ b/drivers/acpi/sysfs.c > @@ -346,11 +346,22 @@ static ssize_t acpi_table_show(struct file *filp, struct kobject *kobj, > return len; > } > > +static bool acpi_table_has_multiple_instances(char *signature) > +{ > + acpi_status status; > + struct acpi_table_header *header; > + > + status = acpi_get_table(signature, 2, &header); > + if (ACPI_FAILURE(status)) > + return false; > + acpi_put_table(header); > + return true; > +} To be honest, I'm not convinced this is the best way to do that. AFAICS there's no guarantee that the second instance would not go away after it had been found and before this returned. Thanks, Rafael