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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 07CF5C433F5 for ; Tue, 17 May 2022 09:29:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.330705.554086 (Exim 4.92) (envelope-from ) id 1nqtVe-0004o8-JR; Tue, 17 May 2022 09:28:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 330705.554086; Tue, 17 May 2022 09:28:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nqtVe-0004o1-Gp; Tue, 17 May 2022 09:28:54 +0000 Received: by outflank-mailman (input) for mailman id 330705; Tue, 17 May 2022 09:28:53 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nqtVd-0004nv-3B for xen-devel@lists.xenproject.org; Tue, 17 May 2022 09:28:53 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nqtVc-0007Pw-KF; Tue, 17 May 2022 09:28:52 +0000 Received: from 54-240-197-227.amazon.com ([54.240.197.227] helo=[10.95.147.55]) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nqtVc-0004of-Dz; Tue, 17 May 2022 09:28:52 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID; bh=ISx1RozKUre99XMm5HKBkqDpV3Tc2zcGV/k2qw3prZY=; b=euRuilHGevu4j/FDLZcgzaZpC3 zoShuLLMag/s2t8sqoYmQtqiuq7XWTVzclgO34O/9G9g0cyV/HpTGi7/+ck+q1g1CbC85z27CQXcn UFVW9Xt92LLIJG0Gt/wW4mrvoyIF26sG56xYzR6vvWY/cEVE+mw6kcxrfLfPKLDfCchM=; Message-ID: <511fd0cb-348f-b65d-cb7b-effd822c7f20@xen.org> Date: Tue, 17 May 2022 10:28:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v4 1/6] xen: do not free reserved memory into heap To: Penny Zheng , "xen-devel@lists.xenproject.org" Cc: Wei Chen , Andrew Cooper , George Dunlap , Jan Beulich , Stefano Stabellini , Wei Liu References: <20220510022733.2422581-1-Penny.Zheng@arm.com> <20220510022733.2422581-2-Penny.Zheng@arm.com> <2ebda9bb-8045-56ec-619b-d0178d57ee17@xen.org> From: Julien Grall In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 17/05/2022 09:21, Penny Zheng wrote: > Yes, I remembered that asynchronous is still on the to-do list for static memory. > > If it doesn't bother too much to you, I would like to ask some help on this issue, ;). > I only knew basic knowledge on the scrubbing, My kwnoledge on the scrubbing code is not much better than yours :). > I knew that dirty pages is placed at the > end of list heap(node, zone, order) for scrubbing and "first_dirty" is used to track down > the dirty pages. IMO, Both two parts are restricted to the heap thingy, not reusable for > static memory, That's correct. > so maybe I need to re-write scrub_free_page for static memory, and also > link the need-to-scrub reserved pages to a new global list e.g. dirty_resv_list for aync > scrubbing? So I can foresee two problems with scrubbing static memory: 1) Once the page is scrubbed, we need to know which domain it belongs so we can link the page again 2) A page may still wait for scrubbing when the domain allocate memory (IOW the reserved list may be empty). So we need to find a page belonging to the domain and then scrubbed. The two problems above would indicate that a per-domain scrub list would be the best here. We would need to deal with initial scrubbing differently (maybe a global list as you suggested). I expect it will take some times to implement it properly. While writing this, I was wondering if there is actually any point to scrub pages when the domain is releasing them. Even if they are free they are still belonging to the domain, so scrubbing them is technically not necessary. Any thoughts? >>> { >>> mfn_t mfn = page_to_mfn(pg); >>> unsigned long i; >>> @@ -2653,7 +2657,8 @@ void __init free_staticmem_pages(struct page_info >> *pg, unsigned long nr_mfns, >>> } >>> >>> /* In case initializing page of static memory, mark it PGC_reserved. */ >>> - pg[i].count_info |= PGC_reserved; >>> + if ( !(pg[i].count_info & PGC_reserved) ) >> >> NIT: I understand the flag may have already been set, but I am not convinced if >> it is worth checking it and then set. >> > > Jan suggested that since we remove the __init from free_staticmem_pages, it's now in preemptable > state at runtime, so better be adding this check here. Well, count_info is already modified within that loop (see mark_page_free()). So I think the impact of setting PGC_reserved is going to be meaningless. However... mark_page_free() is going to set count_info to PGC_state_free and by consequence clear PGC_reserved. Theferore, in the current implementation we always need to re-set PGC_reserved. So effectively, the "if" is pointless here. Cheers, -- Julien Grall