Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp809352rdg; Wed, 11 Oct 2023 06:16:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbezfWZ7/i0QlhjPdZBuvB4kutVJ7am0tReWbSAkIbsmipppwDssA/Q/KPNEldF4ZZvGqw X-Received: by 2002:a05:6a21:998a:b0:13f:13cb:bc50 with SMTP id ve10-20020a056a21998a00b0013f13cbbc50mr27777736pzb.25.1697030186509; Wed, 11 Oct 2023 06:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697030186; cv=none; d=google.com; s=arc-20160816; b=D/tGs6cKgw2EX4NF/gP/FtaoNi1QFwQ5PgqxtZzfpVvx5CClR+ReJMeQZlxTBL+yMy yG31yqFD5/X1J7sX1qd/2Q9qqwRk3ZguOfD1e8yDbP87lMm4Va5Dlt89Uw1rdKaXLEmb dc85Atd2j1S15NNGElFo9gmziRzyyd9z5xRKZQ83lEi5411rd3Y/s68cJDhcplDILd+e kA5XoOLTBoRYAV6vLB7HtpuzxX5HWyBUj/bCrtFNfPuXA764kuv3NEp/arvnmd8k3PBy 0tnXqInwnuCK6r/kWil11S/fsbJ2MVh29x0Ag/mr9Gl3lAvk8+eC+oIEPebdgc3lkjPU fzzg== 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=+XvQ0P5KobJbUd1omMGt95HrItrTtgUxGwsdeCEEEOU=; fh=HXgKhMpP3NR0oFIvtr7coEU3Z/s2pWD4Y60/u8oLjgg=; b=wSKBQ/mGbyy25zss4t/oQORyycBVPxq575K4zfSVkZLeOzHkNC3L+BT0MM+cmDGfSF j/l4rm8PszcixXwzMfrsXU4aJ1uQmVvhNsRKBlfUVVMWsugicaq3f7JKF3Qzf+2+ceyl BIExpPcwwLrctlqRsMVgwHCKHfjNRhR3doNSywMbTZGwReaAN/0t5RNaGIzE/EUrEimq ZSkfjLxni1wxqqcYYbJqXX0kI+ZdnVs11NmLm+c8q7WYRDhxBFCL5BVKBRYcgiuWWmN0 CsI+rUr8dl7ltFsgO4UqiX/CsnkGMJ60W15Ke6kLlawx30mn4uJ0R4H9xJGEIsEXzFD9 AK9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QUFKq1q3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id q4-20020a63d604000000b005829e84158dsi5018533pgg.503.2023.10.11.06.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 06:16:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QUFKq1q3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 5009F80758ED; Wed, 11 Oct 2023 06:15:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346756AbjJKNPG (ORCPT + 99 others); Wed, 11 Oct 2023 09:15:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234871AbjJKNPF (ORCPT ); Wed, 11 Oct 2023 09:15:05 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38CA293 for ; Wed, 11 Oct 2023 06:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697030103; x=1728566103; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=DVj1IAQaMNXzKm35tzE0vtrTuSeRAxpGGOqdY2NfLZ8=; b=QUFKq1q3r+IlEvuEz8y83el89ToG0wCjwagfgjYn5Hm5DjB65G2NZWSL MoHat+lD+RObJZrhieA4JYNjPkoFcxsHXXeWSj9+/ui3n43bhbDAkZvlq H9Pxq+Nw9jsRFzbh7nmh4uo9XmGzEBphH6E8FH02ldJZE30THqkUv6Vn9 WLDYO4JIftca31keim86iuaA+21dif3oS1hVHk3HiESD+7OZRQq09mGzp VS9JWNmE1Gt1JHoFJowBraalY3cdmmH0o/D86wlrE6JQBwYJQnXIVdEuv /U3/ZlUPgdugPKw58pkpB94ebZlcOIQ2r9kHzfGVK3vRtpXol6Wf8h6Ko Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="388525164" X-IronPort-AV: E=Sophos;i="6.03,216,1694761200"; d="scan'208";a="388525164" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 06:15:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10860"; a="870138127" X-IronPort-AV: E=Sophos;i="6.03,216,1694761200"; d="scan'208";a="870138127" Received: from laptop-dan-intel.ccr.corp.intel.com (HELO box.shutemov.name) ([10.252.56.166]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 06:14:56 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id D5B19109FB5; Wed, 11 Oct 2023 16:14:52 +0300 (+03) Date: Wed, 11 Oct 2023 16:14:52 +0300 From: "kirill.shutemov@linux.intel.com" To: "Huang, Kai" Cc: "tglx@linutronix.de" , "mingo@redhat.com" , "x86@kernel.org" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "Edgecombe, Rick P" , "Reshetova, Elena" , "Nakajima, Jun" , "rafael@kernel.org" , "peterz@infradead.org" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "Hunter, Adrian" , "thomas.lendacky@amd.com" , "linux-kernel@vger.kernel.org" , "kexec@lists.infradead.org" , "linux-coco@lists.linux.dev" Subject: Re: [PATCH 09/13] x86/tdx: Account shared memory Message-ID: <20231011131452.r42nemcajjcj77hq@box.shutemov.name> References: <20231005131402.14611-1-kirill.shutemov@linux.intel.com> <20231005131402.14611-10-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=2.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 11 Oct 2023 06:15:16 -0700 (PDT) X-Spam-Level: ** On Tue, Oct 10, 2023 at 10:05:21AM +0000, Huang, Kai wrote: > > > +#ifdef CONFIG_DEBUG_FS > > +static int tdx_shared_memory_show(struct seq_file *m, void *p) > > +{ > > + unsigned long addr, end; > > + unsigned long found = 0; > > + > > + addr = PAGE_OFFSET; > > + end = PAGE_OFFSET + get_max_mapped(); > > + > > + while (addr < end) { > > + unsigned long size; > > + unsigned int level; > > + pte_t *pte; > > + > > + pte = lookup_address(addr, &level); > > + size = page_level_size(level); > > + > > + if (pte && pte_decrypted(*pte)) > > + found += size / PAGE_SIZE; > > + > > + addr += size; > > This could be a long loop, perhaps add cond_resched() here? Sure. -- Kiryl Shutsemau / Kirill A. Shutemov