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 B9BC3C433FE for ; Thu, 16 Dec 2021 10:52:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B6826B0078; Thu, 16 Dec 2021 05:52:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 166AC6B007B; Thu, 16 Dec 2021 05:52:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F24BB6B007D; Thu, 16 Dec 2021 05:52:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0085.hostedemail.com [216.40.44.85]) by kanga.kvack.org (Postfix) with ESMTP id DD6B96B0078 for ; Thu, 16 Dec 2021 05:52:44 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 911878249980 for ; Thu, 16 Dec 2021 10:52:34 +0000 (UTC) X-FDA: 78923343828.17.EA5BBB8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id F3B0714000C for ; Thu, 16 Dec 2021 10:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639651953; 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=K8uTzGYoOBRJY7w+8Ql8RIVF0k5wL483NDOt+n6WV+4=; b=eUavkviYiOuZTNzFf4JXnUBVqBlXM0LXRNtOsKv7DlP4r30dPhaac2yGXMkI1h5h5Tz4fB 8mBdmzBjbywaiTX627MrU6mM5h2h0ItFAci5Vv6O0jSL9LXNp3GCIw9vx92mCYqQ4Ob/gn bAACn8DLo06oikN7L6ctYyRSctK8DDQ= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-327-WVKbgzphOXSN4EDk7S0n2w-1; Thu, 16 Dec 2021 05:52:29 -0500 X-MC-Unique: WVKbgzphOXSN4EDk7S0n2w-1 Received: by mail-wm1-f70.google.com with SMTP id 187-20020a1c02c4000000b003335872db8dso13676930wmc.2 for ; Thu, 16 Dec 2021 02:52:29 -0800 (PST) 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:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=K8uTzGYoOBRJY7w+8Ql8RIVF0k5wL483NDOt+n6WV+4=; b=QXkH37yvz/FtWPvWHtR5nINZDHiSZRHN9B0NpFz5BX1NtrXbE7MUDP+Cp18WP7f+Li MK9iaSRZ4WDE5aqEjqRfVG3tOX2kyKTkb+6aaRM2mc2gXAR5BxdcDRG4erEBe/24Ppl6 c0muLwSBHswbN4qbMKwSIQ++3bP/JVDpgfctxY/NMsV8uoISsZ6U4Zxn13OlncRdwTGq ryYmEysu57VJ15AxGVycyUJUnStaZjJ3OExXEJPDDJF8r9fZQ+Ajbdbqfw13YYBUBZeS /MCEdTvSFl7AWblEY3Sccjz/yvEL1d35X/U2VuZny0BuO4LCTGeQkgA54Vb8RTO8g5Jh qgaA== X-Gm-Message-State: AOAM531Kl3qAUqFq2qpBstLWyqzy1zJz966TaoMtfZHRBjLw0a0qr/ue EuEnwtL1MgqXmqnxJJavANn/FaiYoGQPaE6kz5fnHPIiLkhQpZDVEOF1NWRuSVzHEvKxsoHX3Dl XYwCF152hGfM= X-Received: by 2002:a5d:6b81:: with SMTP id n1mr8498334wrx.56.1639651948619; Thu, 16 Dec 2021 02:52:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHuwZkDO7xDTGVXnkIzmCOOqyhEHNs5qWSXjlASQ9huiT2CqWmGIwoAlwyq1QAUc8hqk8taw== X-Received: by 2002:a5d:6b81:: with SMTP id n1mr8498324wrx.56.1639651948362; Thu, 16 Dec 2021 02:52:28 -0800 (PST) Received: from [192.168.3.132] (p4ff23dcd.dip0.t-ipconnect.de. [79.242.61.205]) by smtp.gmail.com with ESMTPSA id e11sm5582137wrq.28.2021.12.16.02.52.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Dec 2021 02:52:27 -0800 (PST) Message-ID: <0091b689-54b6-7cc9-d5ee-ae12a2f8376d@redhat.com> Date: Thu, 16 Dec 2021 11:52:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v3 3/5] mm_zone: add function to check if managed dma zone exists To: Baoquan He , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, hch@lst.de, cl@linux.com, John.p.donnelly@oracle.com, kexec@lists.infradead.org, stable@vger.kernel.org References: <20211213122712.23805-1-bhe@redhat.com> <20211213122712.23805-4-bhe@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20211213122712.23805-4-bhe@redhat.com> 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 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eUavkviY; spf=none (imf26.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: F3B0714000C X-Stat-Signature: 7wi3qs4zop6bog1fmi1ruiz6ggm3naer X-HE-Tag: 1639651953-949225 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 13.12.21 13:27, Baoquan He wrote: > In some places of the current kernel, it assumes that dma zone must have > managed pages if CONFIG_ZONE_DMA is enabled. While this is not always true. > E.g in kdump kernel of x86_64, only low 1M is presented and locked down > at very early stage of boot, so that there's no managed pages at all in > DMA zone. This exception will always cause page allocation failure if page > is requested from DMA zone. > > Here add function has_managed_dma() and the relevant helper functions to > check if there's DMA zone with managed pages. It will be used in later > patches. > > Fixes: 6f599d84231f ("x86/kdump: Always reserve the low 1M when the crashkernel option is specified") > Cc: stable@vger.kernel.org > Signed-off-by: Baoquan He > --- > v2->v3: > Rewrite has_managed_dma() in a simpler and more efficient way which is > sugggested by DavidH. > > include/linux/mmzone.h | 9 +++++++++ > mm/page_alloc.c | 15 +++++++++++++++ > 2 files changed, 24 insertions(+) > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index 58e744b78c2c..6e1b726e9adf 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -1046,6 +1046,15 @@ static inline int is_highmem_idx(enum zone_type idx) > #endif > } > > +#ifdef CONFIG_ZONE_DMA > +bool has_managed_dma(void); > +#else > +static inline bool has_managed_dma(void) > +{ > + return false; > +} > +#endif > + > /** > * is_highmem - helper function to quickly check if a struct zone is a > * highmem zone or not. This is an attempt to keep references > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index c5952749ad40..7c7a0b5de2ff 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -9460,3 +9460,18 @@ bool take_page_off_buddy(struct page *page) > return ret; > } > #endif > + > +#ifdef CONFIG_ZONE_DMA > +bool has_managed_dma(void) > +{ > + struct pglist_data *pgdat; > + > + for_each_online_pgdat(pgdat) { > + struct zone *zone = &pgdat->node_zones[ZONE_DMA]; > + > + if (managed_zone(zone)) > + return true; > + } > + return false; > +} > +#endif /* CONFIG_ZONE_DMA */ > Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb