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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DD59C433EF for ; Fri, 17 Jun 2022 09:54:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234921AbiFQJy1 (ORCPT ); Fri, 17 Jun 2022 05:54:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380092AbiFQJyZ (ORCPT ); Fri, 17 Jun 2022 05:54:25 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CE844AE2C; Fri, 17 Jun 2022 02:54:24 -0700 (PDT) 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-out1.suse.de (Postfix) with ESMTPS id 52DD021C94; Fri, 17 Jun 2022 09:54:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1655459663; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zG2cqcDSXyzEvp5pVF9J1GNp84hIzLKr5Bwlm1OtUos=; b=fYDb7qEjT6oS5z9kwaQkczLFF3PPeqPcqRDmr2MpJlZLGF16glOXU2IlKNWSd/PjZK4OzO n1ckLKV4vxlzBpnHZL5CYrRjQDJlHD4lAO1EWFBTk8D8mn25FJNZoTz+a6K51qGY+1FFk1 hVOqQ1euxW3Q1vl4/80FdC6E4s1JWyI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1655459663; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zG2cqcDSXyzEvp5pVF9J1GNp84hIzLKr5Bwlm1OtUos=; b=UKL/MDgbZ5+ZWynN5FFH+8Jm2XrytgHofQZl6xnqeSlGuab+NWFhsiZryhY9S2SR4DOZE3 FLNZEpcajUBLO2AQ== 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 AB8F41348E; Fri, 17 Jun 2022 09:54:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id K5YqJ05PrGLDOwAAMHmgww (envelope-from ); Fri, 17 Jun 2022 09:54:22 +0000 Date: Fri, 17 Jun 2022 11:54:21 +0200 From: Oscar Salvador To: David Hildenbrand Cc: Muchun Song , corbet@lwn.net, akpm@linux-foundation.org, paulmck@kernel.org, mike.kravetz@oracle.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, smuchun@gmail.com Subject: Re: [PATCH v2 2/2] mm: memory_hotplug: introduce SECTION_CANNOT_OPTIMIZE_VMEMMAP Message-ID: References: <20220520025538.21144-1-songmuchun@bytedance.com> <20220520025538.21144-3-songmuchun@bytedance.com> <53024884-0182-df5f-9ca2-00652c64ce36@redhat.com> <24d5ec20-9c9e-93aa-11f4-c4619f51f7d1@redhat.com> <186924ab-651f-71a1-93d2-3500a67dffee@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <186924ab-651f-71a1-93d2-3500a67dffee@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Fri, Jun 17, 2022 at 09:43:33AM +0200, David Hildenbrand wrote: > VmemmapSelfHosted, then the function names get nicer. Definitely. > > > +#endif > > + > > /* > > * On an anonymous page mapped into a user virtual memory area, > > * page->mapping points to its anon_vma, not to a struct address_space; > > diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c > > index 1089ea8a9c98..e2de7ed27e9e 100644 > > --- a/mm/hugetlb_vmemmap.c > > +++ b/mm/hugetlb_vmemmap.c > > @@ -101,6 +101,14 @@ void hugetlb_vmemmap_free(struct hstate *h, struct page *head) > > { > > unsigned long vmemmap_addr = (unsigned long)head; > > unsigned long vmemmap_end, vmemmap_reuse, vmemmap_pages; > > + struct mem_section *ms = __pfn_to_section(page_to_pfn(head)); > > + struct page *memmap; > > + > > + memmap = sparse_decode_mem_map(ms->section_mem_map, > > + pfn_to_section_nr(page_to_pfn(head))); > > Why can't we check the head page directly? Either I need more coffee or > this can be simplified. Uhm, maybe I'm the one who needs coffe here but we have something like: [ hot-plugges section ] [memmap pages][normal pages] we only mark as VmemmapSelfHosted the memmap pages. head page points to [normal pages] range, that is why we need to go and get its mem_map to see whether those pages are marked. Does it make sense? Or am I missing something? > > + > > + if (PageVmemmap_self_hosted(memmap)) > > Maybe that's the right place for a comment, an ascii art, and how it is > safe to only check the first vmemmap page due to alignment restrictions. Yes, definitely worth putting in a comment. > > + /* > > + * Let us flag self-hosted memmap > > + */ > > I think that comment can be dropped because the code does exactly that. Yeah, was mainly to picture it, but it needs to go as it is worthless. -- Oscar Salvador SUSE Labs