From patchwork Tue Aug 10 09:48:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 12428549 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=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 E652EC4338F for ; Tue, 10 Aug 2021 09:48:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 77B9261051 for ; Tue, 10 Aug 2021 09:48:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 77B9261051 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id E4E6C6B0071; Tue, 10 Aug 2021 05:48:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DFE618D0001; Tue, 10 Aug 2021 05:48:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D142A6B0073; Tue, 10 Aug 2021 05:48:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id B9AE66B0071 for ; Tue, 10 Aug 2021 05:48:51 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3AE9B8249980 for ; Tue, 10 Aug 2021 09:48:51 +0000 (UTC) X-FDA: 78458696862.01.B0B605A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf07.hostedemail.com (Postfix) with ESMTP id C2D311001BC0 for ; Tue, 10 Aug 2021 09:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628588930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=59kuAZem85KPEOYWVkAOsAR4DDZk1OeL3s1/rT3mByM=; b=ZZHNb6Ij3Duc7VyXBGF+Z56HqmJwUp8+aYDrN3qpKliaiM/J27KVnbvL0HLTkDnZVkwy+L HXIrAAr+8AC4rc/DzsyWVEFFTI8YqUQwD4QM8+qC627zTHdO7sYqbQslnB2yeIeQpSHEUH GNDHSsSsEAk63tuERSG8Abnf6PGJJWg= 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-435-qAtR2cvPMSGga2PEXQO7nw-1; Tue, 10 Aug 2021 05:48:46 -0400 X-MC-Unique: qAtR2cvPMSGga2PEXQO7nw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BAB24875049; Tue, 10 Aug 2021 09:48:44 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-79.pek2.redhat.com [10.72.12.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7396410013C1; Tue, 10 Aug 2021 09:48:39 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, hch@lst.de, robin.murphy@arm.com, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, vbabka@suse.cz, m.szyprowski@samsung.com, rppt@linux.ibm.com, Baoquan He Subject: [RFC PATCH v2 0/5] Avoid requesting page from DMA zone when no managed pages Date: Tue, 10 Aug 2021 17:48:30 +0800 Message-Id: <20210810094835.13402-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZZHNb6Ij; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf07.hostedemail.com: domain of bhe@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=bhe@redhat.com X-Stat-Signature: k4818hmods6yo58mftjc6hd1sn1k5psn X-Rspamd-Queue-Id: C2D311001BC0 X-Rspamd-Server: rspam01 X-HE-Tag: 1628588930-441650 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: In some places of the current kernel, it assumes that DMA zone must have managed pages and try to request 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. E.g in kdump kernel of x86_64, atomic_pool_dma which is created with GFP_DMA will cause page allocation failure, and dma-kmalloc initialization also caused page allocation failure. In this v2 patchset: * Patch 1, 2 are clean up patches of atomic pool code when read code. * Patch 3 introduces helper functions to help check if DMA zone with managed pages exists. * Patch 4 is to check if managed DMA zone exists, then create atomic_pool_dma if yes. * Patch 5 is to check if managed DMA zone exists, then create * dma-kmalloc cache if yes. This is v1 post: https://lore.kernel.org/lkml/20210624052010.5676-1-bhe@redhat.com/ v1->v2: In v1, I tried to adjust code to allow user to disable atomic pool completely with "coherent_pool=0" kernek parameter, then expect to add this into kdump kernel to mute the page allocation failure. However, later found atomic pool is needed when DMA_DIRECT_REMAP=y or mem_encrypt_active() is true, and dma-kmalloc also always caused page allocation failure. So in this v2, change to check if managed DMA zone exists. If DMA zone has managed pages, we go further to request page from DMA zone to initialize. Otherwise, just skip to initialize stuffs which need pages from DMA zone. Baoquan He (5): docs: kernel-parameters: Update to reflect the current default size of atomic pool dma-pool: allow user to disable atomic pool mm_zone: add function to check if managed dma zone exists dma/pool: create dma atomic pool only if dma zone has mamaged pages mm/slub: do not create dma-kmalloc if no managed pages in DMA zone .../admin-guide/kernel-parameters.txt | 5 ++++- include/linux/mmzone.h | 21 +++++++++++++++++++ kernel/dma/pool.c | 11 ++++++---- mm/page_alloc.c | 11 ++++++++++ mm/slab_common.c | 6 ++++++ 5 files changed, 49 insertions(+), 5 deletions(-)