Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1551526lqp; Mon, 15 Apr 2024 09:32:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVD9+HvTogOw9OSRFovC7rAXTtbjkU/+U1vlc6uVmJEa4PRDARBRCEyaKnTquKJi5NOclJmOGkeOfWr3Ba93v7UOQkds7Yw2+A6kNXTxA== X-Google-Smtp-Source: AGHT+IFID/+1gkHMUXXVnuegvvk+u3ABwMiwJ9lfBaofCkrnXCePnm7ypsR9MX0BG8XeJYC31LvF X-Received: by 2002:ad4:58d1:0:b0:69b:1c78:158d with SMTP id dh17-20020ad458d1000000b0069b1c78158dmr9610045qvb.53.1713198753875; Mon, 15 Apr 2024 09:32:33 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dr16-20020a05621408f000b0069b3b41d564si9938658qvb.136.2024.04.15.09.32.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 09:32:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145555-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=hDAALKxn; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-145555-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145555-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 20E8A1C2121D for ; Mon, 15 Apr 2024 16:32:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A203736B; Mon, 15 Apr 2024 16:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hDAALKxn" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4C4C1CD23; Mon, 15 Apr 2024 16:32:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713198740; cv=none; b=Ja2sahRhEdNuXNIixMGr/hu83BLxsZLWfnQPiv8W5UjLGpfnzrcJx+QQHR+1YC24cCdELmup5VKOI3dDqQuEKzM1E4/i+BsaREYcRpBqAQ8NUHwhICjotTfA0TNgEa63qzDVOxbwyl1sN0XMYUbqn3x6oeKZvTEBnTa3ycA+MRk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713198740; c=relaxed/simple; bh=Wsb9mO0IMUs6XyEA7C68rG60ROTwki5oNLgFkNQGVfw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XEb4L3hZx/kVXZ15ajtVDPRUXB1pekZkDMZOjwqnpViKSAL9NI35n1qzEPHb5U7M4fT4zlbuLgTe6Atd3DFQdghmJ6mnnuP/xhUAxQIIZ0Q/Nob3cFI9+FeI5n1O8nOjgg5YPk7sVqGm9tptBNKK+NzbfJpLgHEL2tlpsG7jXU4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hDAALKxn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06B94C113CC; Mon, 15 Apr 2024 16:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713198740; bh=Wsb9mO0IMUs6XyEA7C68rG60ROTwki5oNLgFkNQGVfw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hDAALKxniYNrhPk7bGdZS6/mD+2lHE9dUHGMqBLvm6ZfPtEwssQoA88x2UurOeeN2 ltpjL7kJB+XXWqoHe229s83KYjjbNhr9s8SHH4V8sYGTU8jYDxwjJPZj6AePV4lA8b ucSkbhHoj6CaQkA14qENjkLbGPeW4JGeF4hFAiuWTTcfNQAY1HQduj3z9VMS9GkycQ DI7pojk9FqjWIQKB9JOzHezwyg3iSRcpIh6jRjb4u7T+xoW+knmBlCsRpL4PjkuKxt 3I4/YTgREcipydZmtPp5swjdQqI1Yiru8u7SZ6TNxrZoamRL8MZrxxYxDTBcD05esc hq8v/xfZ4MvHQ== Date: Mon, 15 Apr 2024 17:32:12 +0100 From: Simon Horman To: Yi-De Wu Cc: Yingshiuan Pan , Ze-Yu Wang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , Catalin Marinas , Will Deacon , Richard Cochran , Matthias Brugger , AngeloGioacchino Del Regno , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, David Bradil , Trilok Soni , My Chuang , Shawn Hsiao , PeiLun Suei , Liju Chen , Willix Yeh , Kevenny Hsieh Subject: Re: [PATCH v10 19/21] virt: geniezone: Provide individual VM memory statistics within debugfs Message-ID: <20240415163212.GE2320920@kernel.org> References: <20240412065718.29105-1-yi-de.wu@mediatek.com> <20240412065718.29105-20-yi-de.wu@mediatek.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240412065718.29105-20-yi-de.wu@mediatek.com> On Fri, Apr 12, 2024 at 02:57:16PM +0800, Yi-De Wu wrote: > From: "Jerry Wang" > > Created a dedicated per-VM debugfs folder under gzvm, providing > user-level programs with easy access to per-VM memory statistics for > debugging and profiling purposes. This enables users to effectively > analyze and optimize the memory usage of individual virtual machines. > > Two types of information can be obtained: > > `cat /sys/kernel/debug/gzvm/-/protected_hyp_mem` shows memory > used by the hypervisor and the size of the stage 2 table in bytes. > > `cat /sys/kernel/debug/gzvm/-/protected_shared_mem` gives > memory used by the shared resources of the guest and host in bytes. > > For example: > console:/ # cat /sys/kernel/debug/gzvm/3417-15/protected_hyp_mem > 180328 > console:/ # cat /sys/kernel/debug/gzvm/3417-15/protected_shared_mem > 262144 > console:/ # > > More stats will be added in the future. > > Signed-off-by: Jerry Wang > Signed-off-by: Liju-Clr Chen > Signed-off-by: Yi-De Wu .. > diff --git a/drivers/virt/geniezone/gzvm_vm.c b/drivers/virt/geniezone/gzvm_vm.c .. > @@ -398,6 +409,113 @@ static void setup_vm_demand_paging(struct gzvm *vm) > } > } > > +static int debugfs_open(struct inode *inode, struct file *file) > +{ > + file->private_data = inode->i_private; > + return 0; > +} nit: Coccinelle suggests that simple_open() can be used in place of the debugfs_open() implementation above. .. > +static const struct file_operations hyp_mem_fops = { > + .owner = THIS_MODULE, > + .open = debugfs_open, > + .read = hyp_mem_read, > + .llseek = no_llseek, > +}; > + > +static const struct file_operations shared_mem_fops = { > + .owner = THIS_MODULE, > + .open = debugfs_open, > + .read = shared_mem_read, > + .llseek = no_llseek, > +}; ..