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 X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AFEBC433E9 for ; Tue, 2 Feb 2021 08:35:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A943564EEE for ; Tue, 2 Feb 2021 08:35:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A943564EEE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2A1CD6B006C; Tue, 2 Feb 2021 03:35:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2795E6B006E; Tue, 2 Feb 2021 03:35:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B6FA6B0070; Tue, 2 Feb 2021 03:35:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id 062B66B006C for ; Tue, 2 Feb 2021 03:35:21 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C9F6C3631 for ; Tue, 2 Feb 2021 08:35:20 +0000 (UTC) X-FDA: 77772668400.21.wire43_3815684275c9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id A8F97180442C0 for ; Tue, 2 Feb 2021 08:35:20 +0000 (UTC) X-HE-Tag: wire43_3815684275c9 X-Filterd-Recvd-Size: 5346 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Feb 2021 08:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612254919; h=from:from:reply-to:subject:subject: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=4NY/G36GtP697RjgpeOLFmdF2+6N5HezZacpHU3/OHU=; b=I8MJiwQzNvvyFAYgT2m6w6tOZSjVJmx9lUO+JyQA4+l+dgjsHnCZjZOXpr2+p4wmHUd5zr E9q4sh2bYp9mdLbgWdah4xXZHCmyp1chA8QBWs7YGSL9rsA23drZJVPoRkqftQJztD7pcl t0NGSP2aIg97kF0p6cMQNqLkANc296U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-482-lPodgu1jNaaMDod5g1K1VQ-1; Tue, 02 Feb 2021 03:35:15 -0500 X-MC-Unique: lPodgu1jNaaMDod5g1K1VQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A306B107ACE4; Tue, 2 Feb 2021 08:35:13 +0000 (UTC) Received: from [10.36.114.148] (ovpn-114-148.ams2.redhat.com [10.36.114.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A53A1975E; Tue, 2 Feb 2021 08:35:10 +0000 (UTC) To: Oscar Salvador Cc: Andrew Morton , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210129064045.18471-1-osalvador@suse.de> <20210202075243.GA7037@linux> From: David Hildenbrand Organization: Red Hat GmbH Subject: Re: [PATCH v2] x86/vmemmap: Handle unpopulated sub-pmd ranges Message-ID: Date: Tue, 2 Feb 2021 09:35:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20210202075243.GA7037@linux> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: >> IMHO, we should rip out that code here and enforce page alignment in >> vmemmap_populate()/vmemmap_free(). >> >> Am I missing something? >=20 > Thanks David for bringing this up, I must say I was not aware that this > topic was ever discussed. Yeah, last time I raised it was in https://lkml.kernel.org/r/20200703013435.GA11340@L-31X9LVDL-1304.local but I never got to clean it up myself. >=20 > Ok, I've been having a look into this. > At first I was concerced because of a pure SPARSEMEM configuration, but= I > see that those allocations are done in a very diferent way so it does n= ot > bother us. >=20 > So we have the following enforcements during hotplug: >=20 > add_memory_resource > check_hotplug_memory_range : Checks range aligned to memory_block_siz= e_bytes, > : which means it must be section-size alig= ned >=20 > populate_section_memmap > __populate_section_memmap : Checks range aligned to sub-section size >=20 > So, IIRC we have two cases during hotplug: > 1) the ones that want memory blocks > 2) the ones that do not want them (pmem stuff) >=20 > For #1, we always enforce section alignment in add_memory_resource, and= for > #2 we always make sure the range is at least sub-section aligned. >=20 > And the important stuff is that boot memory is no longer to be hot-remo= ved > (boot memory had some strange layout sometimes). The vmemmap of boot mem sections is always fully populated, even with=20 strange memory layouts (e.g., see comment in pfn_valid()). In addition,=20 we can only offline+remove whole sections, so that should be fine. >=20 > So, given the above, I think it should be safe to drop that check in > remote_pte_table. > But do we really need to force page alignment in vmemmap_populate/vmemm= ap_free? > vmemmap_populate should already receive a page-aligned chunk because > __populate_section_memmap made sure of that, and vmemmap_free() shoul= d be ok > as we already filtered out at hot-adding stage. >=20 > Of course, this will hold as long as struct page size of multiple of 8. > Should that change we might get trouble, but I do not think that can ev= er > happened (tm). >=20 > But anyway, I am fine with placing a couple of checks in vmemmap_{popul= ate,free} > just to double check. >=20 > What do you think? I'd just throw in 1 or 2 VM_BUG_ON() to self-document what we expect and=20 that we thought about these conditions. It's then easy to identify the=20 relevant commit where we explain the rationale. I don't have a strong opinion, the other archs also don't seem to care=20 about documenting/enforcing it. --=20 Thanks, David / dhildenb