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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66E0CC43334 for ; Tue, 12 Jul 2022 07:31:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C90CD940052; Tue, 12 Jul 2022 03:31:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C1966940033; Tue, 12 Jul 2022 03:31:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A93E0940052; Tue, 12 Jul 2022 03:31:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 93EC8940033 for ; Tue, 12 Jul 2022 03:31:15 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5FED020ED0 for ; Tue, 12 Jul 2022 07:31:15 +0000 (UTC) X-FDA: 79677626910.16.46D4E85 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id CC1F9140064 for ; Tue, 12 Jul 2022 07:31:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657611074; 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=JbtPsR71iqyPBrbbkf871/FxBajXvobX7r2J0WEifnEvqrZ8d+1f4zcdGwve5QnoDpQhz0 aQLVNXOmBVU0Xt6qUPW40kQtAZ2JxhKSljFMCmu6Cf0l/Y8OlH9fmhnfPy3ugeqTk29cPz aQGCJcZ+lpDac8BttHEU6QZHDoBG/vo= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-t_Xda4usPuSuRVJqtPWG4Q-1; Tue, 12 Jul 2022 03:31:11 -0400 X-MC-Unique: t_Xda4usPuSuRVJqtPWG4Q-1 Received: by mail-wr1-f71.google.com with SMTP id e16-20020adf9bd0000000b0021d9c17e980so1057082wrc.15 for ; Tue, 12 Jul 2022 00:31:10 -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=sjXGtPS84Hn3gokD5cNQ4aKKWcHNkh7RkMOqx8iZCSox3lzSnKki5h4TXzKoD3eu62 QQS55+ENWRH27dYG0BLcBestLJD0lqUxEG/BrUKMJur6Cqia5rV3FYx3T6xaT5s3kHVb Xh26kO7YjZXog/Gnr/EvkmhNfo4nNNtyQkRibFnum36hNJh7V9pTx5K2l1MR4dDSzXNG V/VT0CAIK319DN9BSXQYta74RGvS2OrqZAq7MQCAdhvCI83Wtseqx8etu//jnmHLD9CJ XZC8Ac4hSpG/p6bMehUgf5oySX7zVBJfCUTMMfqfVujj3z62hF8XAuyVDbJG10K9HYxT iKMw== X-Gm-Message-State: AJIora85Xp519UnyuuJ4lFbiNivBqerp4hDI8PYBjeJT8rOntkBt3ehJ yOyM/HxRgo+WNdb250fixYdJbCweY7A/+PKrPJbjxw7sAld8HWJyJeUoQ8vSWJZJgX8zANPFtOP sBNXJZjXuxJ4= X-Received: by 2002:a05:600c:15c7:b0:3a2:dd5d:2514 with SMTP id v7-20020a05600c15c700b003a2dd5d2514mr2325575wmf.31.1657611069945; 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> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657611075; a=rsa-sha256; cv=none; b=7xytHp6QFy6FxFszjhzdDzYqe4KyPSxJQ3anjSlkR4nTUqabBVamd9UqjxHXpz7QxxMf4G PIzrAi9yKVQ46FBDIQwa9ZzDqfI38KaQneM/heyjd/mToF0YPyvoHNheWuT5qRiFYnC+dB lI1BUvJzF0bAuGPrzyI2ru7SPU/tMkg= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JbtPsR71; spf=none (imf26.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657611075; h=from:from:sender: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:dkim-signature; bh=JdO5MxAzmVOyjgWnn1pQedaEsg1HdPJj3a1oJOO8q64=; b=ICApaM62/XncyKjbFPGuqSBktEWSuZBz6HOj3Ukd4UTHTHqgFbVndiP4TFAcvf45zYPcML zZxn/ztnBVVCXY+N/QuPtvdh6ws1h+iITWFm/PIMvXEOyxlqEO66tlQFzoo9wSF0ipxc78 CMkks4g22VCMkelggZ5P8YAz+vS/VHc= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CC1F9140064 X-Rspam-User: X-Stat-Signature: jbya64a7hh1wx4bewjc9z73ncdm95z9j Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JbtPsR71; spf=none (imf26.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1657611074-102463 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: 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