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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 5E3E9C433EF for ; Tue, 12 Jul 2022 07:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Subject:From:References:Cc: To:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FdK9JS/Sjc6XOJScNS9tJi62tA1R5vhfryh2nq9QC+0=; b=ZnY9CFWWez/qcU CY32tXANcOZTY6iBtB89Ej5CHdSKswfkcKdZ3kkN7n2JA4S6pOfwIZ3YPmtz9U3f8CWsT9xm9ujHd 15QXykfOvP0F9FYCdCI5tDDs+AqRtQS3oECrU9LOGSobqfmT2o1lhKpuTzLL91KoKBSwjrWa/vTdd a88C9ufXfrLKrV1qweDNfF2f93nxsOGifhl2dqO6+M2AFvj9SIiol7vE8M87wUD7eDA7MCcNpVg8k 6Z7AycCLeEhx2VX5VbM//PGdb4GmWQt6uL8rTtyWZaUW9ny3WsfbcJsm97qq2dbd96HMP/ujvBwh1 X/S8/Rg7O5zQmkuCkx4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBAMZ-008Lix-1Z; Tue, 12 Jul 2022 07:31:19 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBAMU-008LdU-VS for linux-arm-kernel@lists.infradead.org; Tue, 12 Jul 2022 07:31:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657611072; 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=JdO5MxAzmVOyjgWnn1pQedaEsg1HdPJj3a1oJOO8q64=; b=iHJVuuRSudjtluJfpZNPXkxUbP8DijZwUzWdHSiKbNcPRKwQBIyxlWsJpMTUxQVAARxaAz D5ZaP9MVEqi0wHUd7e/bxzpck7EtGj6wUgIBBA7/jvejVKEtMsVzE1IAx+M60D7L+lJMUI viPphvyLcB+3xrFN+9rLV0Za1ENUbf4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-nFB-svxGMsC7dk08Gp1wxQ-1; Tue, 12 Jul 2022 03:31:11 -0400 X-MC-Unique: nFB-svxGMsC7dk08Gp1wxQ-1 Received: by mail-wr1-f72.google.com with SMTP id m7-20020adfa3c7000000b0021d7ae39d1dso1144782wrb.12 for ; Tue, 12 Jul 2022 00:31:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=JdO5MxAzmVOyjgWnn1pQedaEsg1HdPJj3a1oJOO8q64=; b=Y7NhBMiJr8OpSw4ueArgNvGNHP+/Kiqg21/Mky+gbvKGWJTs1AWv1QAFzCkNtkXBWL kAD+vnzu0Q+QHQWiU7vObPU2QSWUXBZxbelmTPhyaUN452y+RcVfDRcidFEysq84ifC4 ZJSvitVwBdPwnEaU8oz3CHEHtVniGyE0RSwecdbqZ1edkdaeZEhSNyI7LiAtbJXaxL7t 6O4F6serglPQooW6zLS2TY/IErgqAFmpIDrweBhoCI4YR3EfpV+l6D8aL7O72QFpNTDK QfZZHwyU09OHDzKCXPjxTwEmafK1659ktIGIzvcca2M2boLRmuSMjdDY+aLgZLVa9dWd wnbg== X-Gm-Message-State: AJIora9FI8+N/BwevDrS2YwzCX1OPFOpbs+ilfF2WKGIJDAX0YBlBxs1 pP35a4/A+xEfWodrqozViuw7gfv1HuOSES3mBi2UGzmH/KY0xawZDyYca2pKGDwkgK0IJv3fbmy mrkKFDdn7sb4kxW9La/9TF9YBpq2m2xMy3r0= X-Received: by 2002:a05:600c:15c7:b0:3a2:dd5d:2514 with SMTP id v7-20020a05600c15c700b003a2dd5d2514mr2325577wmf.31.1657611069946; Tue, 12 Jul 2022 00:31:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tMaOvFB7ntQolPpHbs5LGtj2RVU3jED0+l76qVjzoYSHfm86bII08rLZtbYEYslh2Mv1KxIg== X-Received: by 2002:a05:600c:15c7:b0:3a2:dd5d:2514 with SMTP id v7-20020a05600c15c700b003a2dd5d2514mr2325544wmf.31.1657611069642; Tue, 12 Jul 2022 00:31:09 -0700 (PDT) Received: from ?IPV6:2003:cb:c703:d900:a75d:cddc:d29f:bdb3? (p200300cbc703d900a75dcddcd29fbdb3.dip0.t-ipconnect.de. [2003:cb:c703:d900:a75d:cddc:d29f:bdb3]) by smtp.gmail.com with ESMTPSA id c9-20020adfed89000000b0021d9233e7e6sm9127869wro.54.2022.07.12.00.31.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Jul 2022 00:31:09 -0700 (PDT) Message-ID: <4cf14bde-fb4c-99d9-58ce-a788a700d5f3@redhat.com> Date: Tue, 12 Jul 2022 09:31:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 To: Li Chen Cc: Catalin Marinas , Will Deacon , Rob Herring , Frank Rowand , Andrew Morton , Li Chen , linux-arm-kernel , linux-kernel , devicetree , linux-mm References: <20220711122459.13773-1-me@linux.beauty> <20220711122459.13773-3-me@linux.beauty> <181f0a5f2a5.cf94ce78513585.4158910057206462182@linux.beauty> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH 2/4] mm/sparse: skip no-map memblock check when fill_subsection_map In-Reply-To: <181f0a5f2a5.cf94ce78513585.4158910057206462182@linux.beauty> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220712_003115_123047_AE15F4E4 X-CRM114-Status: GOOD ( 35.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 12.07.22 06:23, Li Chen wrote: > Hi David, > ---- On Mon, 11 Jul 2022 22:53:36 +0800 David Hildenbrand wrote --- > > On 11.07.22 14:24, Li Chen wrote: > > > From: Li Chen > > > > > > When mhp use sparse_add_section, don't check no-map region, > > > so that to allow no-map reserved memory to get struct page > > > support. > > > > > > Signed-off-by: Li Chen > > > Change-Id: I0d2673cec1b66adf695251037a00c240976b226f > > > --- > > > mm/sparse.c | 4 +++- > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > diff --git a/mm/sparse.c b/mm/sparse.c > > > index 120bc8ea5293..a29cd1e7014f 100644 > > > --- a/mm/sparse.c > > > +++ b/mm/sparse.c > > > @@ -690,7 +690,9 @@ static int fill_subsection_map(unsigned long pfn, unsigned long nr_pages) > > > > > > if (bitmap_empty(map, SUBSECTIONS_PER_SECTION)) > > > rc = -EINVAL; > > > - else if (bitmap_intersects(map, subsection_map, SUBSECTIONS_PER_SECTION)) > > > + else if (memblock_is_map_memory(PFN_PHYS(pfn)) && > > > + bitmap_intersects(map, subsection_map, > > > + SUBSECTIONS_PER_SECTION)) > > > rc = -EEXIST; > > > else > > > bitmap_or(subsection_map, map, subsection_map, > > > > I'm not sure I follow completely what you are trying to achieve. But if > > you have to add memblock hacks into mm/sparse.c you're most probably > > doing something wrong. > > > > Please explain why that change is necessary, and why it is safe. > > In the current sparse memory model, free_area_init will insert all memblock.memory into subsection_map and no-map rmem is also a > memblock.memory. So, without this change, fill_subsection_map will return -EEXIST. > > I would say it's not a good idea to insert no-map memblock into subsection_map, and I have no idea why sparse do this. > So, I simply skip no-map region here. The thing is: if the subsection map is set, then there already *is* a memmap and you would simply be ignoring it (and overwriting a memmap in e.g., ZONE_NORMAL to be in ZONE_DEVICE suddenly, which is wrong). Reading memblock_mark_nomap(): "The memory regions marked with %MEMBLOCK_NOMAP will not be added to the direct mapping of the physical memory. These regions will still be covered by the memory map. The struct page representing NOMAP memory frames in the memory map will be PageReserved()" So having a memmap for these ranges is expected, and a direct map is not desired. What you propose is a hack. You either have to reuse the existing memmap (which is !ZONE_DEVICE -- not sure if that's a problem) or we'd have to look into teaching init code to not allocate a memmap for sub-sections that are fully nomap. But not sure who depends on the existing memmap for nomap memory. > > As for safety: > 1. The caller of fill_subsection_map are mhp and *_memremap_pages functions, no-map regions are not related to them, so existing codes won't be broken. > 2. This change doesn't change memblock and subsection_map. > Sorry, but AFAIKT it's a hack and we need a clean way to deal with nomap memory that already has a memmap instead. -- Thanks, David / dhildenb _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel