From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A99222629F for ; Wed, 22 Nov 2023 14:37:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="yLumXxe+" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-40907b82ab9so5308765e9.1 for ; Wed, 22 Nov 2023 06:37:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700663819; x=1701268619; darn=lists.linux.dev; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=u5S0ovat1Ld2/p/rdzb9E9NFKi5bx+S+NSv6XEPWCA8=; b=yLumXxe+ne3rdP34h1OwqnGhVNWhvDxZGPX3BaPJeuEY06B/SP5TtUKFELOnmnV9Gf z8BYqjT3N44BrqfvJbR8hxSlzTa2UoN4DVV4/JsQhF/L2zNXh3ZuF6fxE4x527gZEL8Z yPEE8U3TWxqbkrMBaTUheVAvGlgs88bqcLrWVufWBKB++ViL1z0pVWuUMs3B8tVvX2AP HqV9cKuNq3LbjPAtPk9BarXQFYX/bE4TZNW6ssb+uGMloMkAEzpuXUZLAzOA5ziTIPeT akNmJVBo/SzMKlF8Nnx31BUKK24CLT3raOmclXlUAIziUpMN3DqtmCewXVTRdyT7c6Lw Mh2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700663819; x=1701268619; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=u5S0ovat1Ld2/p/rdzb9E9NFKi5bx+S+NSv6XEPWCA8=; b=PBA0bn36eIqZ98f6IRBbljOXpikSqO+0Qpwguz95x8mJ25XsCOwW7FbAqKbA4bPNoH Kd9FcqD6+wqeWQE3BD6O+2J8YjJjOA5qRUXu1zGtILOu6d7gmz36MYKesJLvHUNRF+C1 IynY+dgMiToMeB2xk0CeYmICuOm4MGM5SNrdlrPBh0raJXQaCK1kYtcXoZk7YaaVuM9y 2YQ6wJBBxbs4nxFf9SYe7Xz/UBf7DdrhTJgOk0M8uKI5r9W3eSRfFayMImvvgMWWH6J8 nSoyqYACw5kAjc9phkgl7lxiWuAL4rjGFruHcREmTd4LwhAPF5DULpHQ8mE9g/Ok7QMZ sxcg== X-Gm-Message-State: AOJu0YyD1CRkjBjXBnDi/ywmaIL14/xqWgXcoNW5lx/Mog2DEMvuLJq5 WuNelu+lSI1qCegchtq5RXFxTw== X-Google-Smtp-Source: AGHT+IGyi7J+6h3rxcZ1JVou4fsnecYhJwWBZMFmSSMHEMqUjB8YcptrGlhNGF3SydnM1LCIg+pqew== X-Received: by 2002:a5d:47af:0:b0:332:d504:c10a with SMTP id 15-20020a5d47af000000b00332d504c10amr549068wrb.19.1700663818745; Wed, 22 Nov 2023 06:36:58 -0800 (PST) Received: from google.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id i13-20020a5d584d000000b00332cb0937f4sm7730008wrf.33.2023.11.22.06.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 06:36:58 -0800 (PST) Date: Wed, 22 Nov 2023 14:36:54 +0000 From: Vincent Donnefort To: Sebastian Ene Cc: will@kernel.org, Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , catalin.marinas@arm.com, mark.rutland@arm.com, akpm@linux-foundation.org, maz@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, qperret@google.com, smostafa@google.com Subject: Re: [PATCH v3 05/10] arm64: ptdump: Add hooks on debugfs file operations Message-ID: References: <20231115171639.2852644-2-sebastianene@google.com> <20231115171639.2852644-7-sebastianene@google.com> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231115171639.2852644-7-sebastianene@google.com> On Wed, Nov 15, 2023 at 05:16:35PM +0000, Sebastian Ene wrote: > Introduce callbacks invoked when the debugfs entry is accessed from > userspace. This hooks will allow us to allocate and prepare the memory > resources used by ptdump when the debugfs file is opened/closed. > > Signed-off-by: Sebastian Ene > --- > arch/arm64/include/asm/ptdump.h | 7 +++++ > arch/arm64/mm/ptdump_debugfs.c | 53 +++++++++++++++++++++++++++++++-- > 2 files changed, 58 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdump.h > index 1f6e0aabf16a..9b2bebfcefbe 100644 > --- a/arch/arm64/include/asm/ptdump.h > +++ b/arch/arm64/include/asm/ptdump.h > @@ -20,9 +20,16 @@ struct ptdump_info { > const struct addr_marker *markers; > unsigned long base_addr; > void (*ptdump_walk)(struct seq_file *s, struct ptdump_info *info); > + int (*ptdump_prepare_walk)(void *file_priv); > + void (*ptdump_end_walk)(void *file_priv); > }; > > void ptdump_walk(struct seq_file *s, struct ptdump_info *info); > + > +struct ptdump_info_file_priv { > + struct ptdump_info info; > + void *file_priv; > +}; > #ifdef CONFIG_PTDUMP_DEBUGFS > #define EFI_RUNTIME_MAP_END DEFAULT_MAP_WINDOW_64 > void __init ptdump_debugfs_register(struct ptdump_info *info, const char *name); > diff --git a/arch/arm64/mm/ptdump_debugfs.c b/arch/arm64/mm/ptdump_debugfs.c > index 7564519db1e6..3bf5de51e8c3 100644 > --- a/arch/arm64/mm/ptdump_debugfs.c > +++ b/arch/arm64/mm/ptdump_debugfs.c > @@ -7,7 +7,8 @@ > > static int ptdump_show(struct seq_file *m, void *v) > { > - struct ptdump_info *info = m->private; > + struct ptdump_info_file_priv *f_priv = m->private; > + struct ptdump_info *info = &f_priv->info; > > get_online_mems(); > if (info->ptdump_walk) > @@ -15,7 +16,55 @@ static int ptdump_show(struct seq_file *m, void *v) > put_online_mems(); > return 0; > } > -DEFINE_SHOW_ATTRIBUTE(ptdump); > + > +static int ptdump_open(struct inode *inode, struct file *file) > +{ > + int ret; > + struct ptdump_info *info = inode->i_private; > + struct ptdump_info_file_priv *f_priv; > + > + f_priv = kzalloc(sizeof(struct ptdump_info_file_priv), GFP_KERNEL); > + if (!f_priv) > + return -ENOMEM; > + > + memcpy(&f_priv->info, info, sizeof(*info)); That doesn't look right. Why would reading the file need a copy of that? Also, that is a lot of "priv" it's hard to understand which is which. I suppose you need have the description of the pgtable which is created at the same time as the debugfs entry is registered. And you have (or not) the snapshot of the pgtable, which is created only on the file open. > + > + ret = single_open(file, ptdump_show, f_priv); > + if (ret) { > + kfree(f_priv); > + return ret; > + } > + > + if (info->ptdump_prepare_walk) { > + ret = info->ptdump_prepare_walk(f_priv); > + if (ret) > + kfree(f_priv); > + } > + > + return ret; > +} > + [...] From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0477C61D9B for ; Wed, 22 Nov 2023 14:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=caJd6WzECW1wGiGB1FTF/2xioFOuS4NLmSH+NMP6yOM=; b=qz8p2RF5Fow2R6 PZXOnXkn7MLR0Ts4cDPdu1vi3q5E3d6ckLvDgsdCgmAHQQv31fb69EdXlHHMsAdyzGtjQUmtC06af RKHyX+PbAytIrShG2hTyqT5BRj6Hr5KE0wOXU+xnJbgrlo9z3vBLkAFCA3sKs1VKpTp5Wxo/3fq6f wt4bDjWP1PhCYo/nrITboe1wJB92gmta6i09uOmB69VqoJX4PrKJ8V63OHYv9C/ULLYxHAuiu3nGp T9PQTEMALJGEtuFK1MiXr029aLVopJFIm+q3fLVBWIdBfGMflXRCQi3lapgL3jr2LREuR83d5gT3y LVOkvjh75eKKWqMHdXsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5oLk-0027Yi-05; Wed, 22 Nov 2023 14:37:08 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5oLg-0027Y7-2v for linux-arm-kernel@lists.infradead.org; Wed, 22 Nov 2023 14:37:06 +0000 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-332ce3fa438so547451f8f.1 for ; Wed, 22 Nov 2023 06:37:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700663819; x=1701268619; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=u5S0ovat1Ld2/p/rdzb9E9NFKi5bx+S+NSv6XEPWCA8=; b=lhJTM3mDXmMHaZK3PMEuLnIpmPqG8BMyeDUxg70VJw5ug0uuulXCJoE//5yp9++Gz3 Z1gADAMxKVla5qdegGcPSqskju67777AFFL/55I/1Fb2IzKdF69pFQHkcai92bcv04Uz fWK+Q0Z3caFKYdD6TrUUlY5kjRK4yS438YJTN1z3bZ7BlxFLH753pn/AORnk4kSnudp4 LGuUrzxALhvuqikcXhQJtNzY/wOjcQ8jNlOyjyQdblohTBkzavjFRbCJDQI06CIBmESo pQNRY2A2VAGPrIAX23WMLTwDC6aPomhD6Zg1l1TjkIK1dZs+f0KLJHdguCZpv2lLwmzR h6QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700663819; x=1701268619; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=u5S0ovat1Ld2/p/rdzb9E9NFKi5bx+S+NSv6XEPWCA8=; b=EtptYD9dUEC1xh9TCcAaoj+yBc5eq1eRqjxOx5IeV5NvcT/7Oxt+I0OXjq67sAn4u2 LGv2rSVGw16wk+7Uk49bOsSH21MdSBlBOWiqDVsd258fsOvzoX1BBAI+s3ol96OpFoFI D1PrQaaVINL0z0CIVgnkZ7V3G1+8Abt4on+eWqqqjZwSQFOz64518SHJwDbc+GaFnrIy /G5nc8a8ltLdWXStveLFB5rOiL81GlVvRXVF3Ki3HRZxvAzDh3s4RmPnMEPsGMqZlfyT I90ovNSIOpu4CIOdPEtACeffglE35EZquXJmdelNUI4Coae/kID62j9e7ug/wpdVlf63 my2g== X-Gm-Message-State: AOJu0Ywjh94fxQvflaipBa4wxuTK1oSG9QPLWEYBYkA5joA4NxDR5Etq Teb3hkYE89zi1+VFaDJ5pHBKDZlVX9xIC+1Z8bBWoheO X-Google-Smtp-Source: AGHT+IGyi7J+6h3rxcZ1JVou4fsnecYhJwWBZMFmSSMHEMqUjB8YcptrGlhNGF3SydnM1LCIg+pqew== X-Received: by 2002:a5d:47af:0:b0:332:d504:c10a with SMTP id 15-20020a5d47af000000b00332d504c10amr549068wrb.19.1700663818745; Wed, 22 Nov 2023 06:36:58 -0800 (PST) Received: from google.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id i13-20020a5d584d000000b00332cb0937f4sm7730008wrf.33.2023.11.22.06.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 06:36:58 -0800 (PST) Date: Wed, 22 Nov 2023 14:36:54 +0000 From: Vincent Donnefort To: Sebastian Ene Cc: will@kernel.org, Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , catalin.marinas@arm.com, mark.rutland@arm.com, akpm@linux-foundation.org, maz@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@android.com, qperret@google.com, smostafa@google.com Subject: Re: [PATCH v3 05/10] arm64: ptdump: Add hooks on debugfs file operations Message-ID: References: <20231115171639.2852644-2-sebastianene@google.com> <20231115171639.2852644-7-sebastianene@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20231115171639.2852644-7-sebastianene@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231122_063704_950032_818F8EC3 X-CRM114-Status: GOOD ( 24.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Nov 15, 2023 at 05:16:35PM +0000, Sebastian Ene wrote: > Introduce callbacks invoked when the debugfs entry is accessed from > userspace. This hooks will allow us to allocate and prepare the memory > resources used by ptdump when the debugfs file is opened/closed. > > Signed-off-by: Sebastian Ene > --- > arch/arm64/include/asm/ptdump.h | 7 +++++ > arch/arm64/mm/ptdump_debugfs.c | 53 +++++++++++++++++++++++++++++++-- > 2 files changed, 58 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdump.h > index 1f6e0aabf16a..9b2bebfcefbe 100644 > --- a/arch/arm64/include/asm/ptdump.h > +++ b/arch/arm64/include/asm/ptdump.h > @@ -20,9 +20,16 @@ struct ptdump_info { > const struct addr_marker *markers; > unsigned long base_addr; > void (*ptdump_walk)(struct seq_file *s, struct ptdump_info *info); > + int (*ptdump_prepare_walk)(void *file_priv); > + void (*ptdump_end_walk)(void *file_priv); > }; > > void ptdump_walk(struct seq_file *s, struct ptdump_info *info); > + > +struct ptdump_info_file_priv { > + struct ptdump_info info; > + void *file_priv; > +}; > #ifdef CONFIG_PTDUMP_DEBUGFS > #define EFI_RUNTIME_MAP_END DEFAULT_MAP_WINDOW_64 > void __init ptdump_debugfs_register(struct ptdump_info *info, const char *name); > diff --git a/arch/arm64/mm/ptdump_debugfs.c b/arch/arm64/mm/ptdump_debugfs.c > index 7564519db1e6..3bf5de51e8c3 100644 > --- a/arch/arm64/mm/ptdump_debugfs.c > +++ b/arch/arm64/mm/ptdump_debugfs.c > @@ -7,7 +7,8 @@ > > static int ptdump_show(struct seq_file *m, void *v) > { > - struct ptdump_info *info = m->private; > + struct ptdump_info_file_priv *f_priv = m->private; > + struct ptdump_info *info = &f_priv->info; > > get_online_mems(); > if (info->ptdump_walk) > @@ -15,7 +16,55 @@ static int ptdump_show(struct seq_file *m, void *v) > put_online_mems(); > return 0; > } > -DEFINE_SHOW_ATTRIBUTE(ptdump); > + > +static int ptdump_open(struct inode *inode, struct file *file) > +{ > + int ret; > + struct ptdump_info *info = inode->i_private; > + struct ptdump_info_file_priv *f_priv; > + > + f_priv = kzalloc(sizeof(struct ptdump_info_file_priv), GFP_KERNEL); > + if (!f_priv) > + return -ENOMEM; > + > + memcpy(&f_priv->info, info, sizeof(*info)); That doesn't look right. Why would reading the file need a copy of that? Also, that is a lot of "priv" it's hard to understand which is which. I suppose you need have the description of the pgtable which is created at the same time as the debugfs entry is registered. And you have (or not) the snapshot of the pgtable, which is created only on the file open. > + > + ret = single_open(file, ptdump_show, f_priv); > + if (ret) { > + kfree(f_priv); > + return ret; > + } > + > + if (info->ptdump_prepare_walk) { > + ret = info->ptdump_prepare_walk(f_priv); > + if (ret) > + kfree(f_priv); > + } > + > + return ret; > +} > + [...] _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel