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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 CAD9CC001DF for ; Tue, 1 Aug 2023 16:49:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQsYC-0000Uq-5H; Tue, 01 Aug 2023 12:48:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQsYA-0000UR-Jg for qemu-devel@nongnu.org; Tue, 01 Aug 2023 12:48:46 -0400 Received: from smtp-out2.suse.de ([2001:67c:2178:6::1d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qQsY9-0002p4-1U for qemu-devel@nongnu.org; Tue, 01 Aug 2023 12:48:46 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 193821F37F; Tue, 1 Aug 2023 16:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1690908522; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lWB4OxoNL4zke6nToTfy8HwF+ManI7/k360H2pA3+rM=; b=RtZ6LKUrTc/pokJ7IK0o+vtt4UPHiqifpf2zfO4PMTtmrYhrCG4m3QF+XdUXfwrlQtN7j0 9na5LKY4eOELxxMXSCZ8PgHh+F7QeVHvPkzbYtFR0UOhXY9raKOlJVjKxeJgYaVUkNay/I PVfG5ED6EC5Gi2bSyjOQ+/ttrNwYfro= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1690908522; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lWB4OxoNL4zke6nToTfy8HwF+ManI7/k360H2pA3+rM=; b=osUs2P7H/5oypgGThiIpIKUJyWEn+9LrkEncOBd24uCThVsRSdGyujyvnvrJbLeaUhyo7x KOOfupL81o/OZODA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 422FC13919; Tue, 1 Aug 2023 16:48:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Rb2xDWk3yWRsLQAAMHmgww (envelope-from ); Tue, 01 Aug 2023 16:48:41 +0000 Message-ID: <3a14456d-244c-ce8f-9d1c-8bcdb75de81c@suse.de> Date: Tue, 1 Aug 2023 18:48:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [RFC PATCH 04/19] memory: Introduce memory_region_can_be_private() Content-Language: en-US To: Xiaoyao Li , Paolo Bonzini , Sean Christopherson , David Hildenbrand , Igor Mammedov , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Marcelo Tosatti Cc: Markus Armbruster , Eric Blake , =?UTF-8?Q?Daniel_P=2e_Berrang=c3=a9?= , =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , Peter Xu , Chao Peng , Michael Roth , isaku.yamahata@gmail.com, qemu-devel@nongnu.org, kvm@vger.kernel.org References: <20230731162201.271114-1-xiaoyao.li@intel.com> <20230731162201.271114-5-xiaoyao.li@intel.com> From: Claudio Fontana In-Reply-To: <20230731162201.271114-5-xiaoyao.li@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2001:67c:2178:6::1d; envelope-from=cfontana@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.092, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On 7/31/23 18:21, Xiaoyao Li wrote: > Signed-off-by: Xiaoyao Li > --- > include/exec/memory.h | 9 +++++++++ > softmmu/memory.c | 5 +++++ > 2 files changed, 14 insertions(+) > > diff --git a/include/exec/memory.h b/include/exec/memory.h > index 61e31c7b9874..e119d3ce1a1d 100644 > --- a/include/exec/memory.h > +++ b/include/exec/memory.h > @@ -1679,6 +1679,15 @@ static inline bool memory_region_is_romd(MemoryRegion *mr) > */ > bool memory_region_is_protected(MemoryRegion *mr); > > +/** > + * memory_region_can_be_private: check whether a memory region can be private The name of the function is not particularly informative, > + * > + * Returns %true if a memory region's ram_block has valid gmem fd assigned. but in your comment you describe more accurately what it does, why not make it the function name? bool memory_region_has_valid_gmem_fd() > + * > + * @mr: the memory region being queried > + */ > +bool memory_region_can_be_private(MemoryRegion *mr); bool memory_region_has_valid_gmem_fd() Thanks, C > + > /** > * memory_region_get_iommu: check whether a memory region is an iommu > * > diff --git a/softmmu/memory.c b/softmmu/memory.c > index 4f8f8c0a02e6..336c76ede660 100644 > --- a/softmmu/memory.c > +++ b/softmmu/memory.c > @@ -1855,6 +1855,11 @@ bool memory_region_is_protected(MemoryRegion *mr) > return mr->ram && (mr->ram_block->flags & RAM_PROTECTED); > } > > +bool memory_region_can_be_private(MemoryRegion *mr) > +{ > + return mr->ram_block && mr->ram_block->gmem_fd >= 0; > +} > + > uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr) > { > uint8_t mask = mr->dirty_log_mask;