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=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 DA60EC388F9 for ; Wed, 11 Nov 2020 14:56:27 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E89EA2068D for ; Wed, 11 Nov 2020 14:56:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UdXRAri0"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Amd18ETl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E89EA2068D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4CWSVJ1knlzDqwY for ; Thu, 12 Nov 2020 01:56:24 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=63.128.21.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=david@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UdXRAri0; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Amd18ETl; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4CWSR94gCkzDqnK for ; Thu, 12 Nov 2020 01:53:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605106417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=5Dr0+pyBqVK3WLFkrmGnVmo0jFKi8+9WQgJ494/SxHE=; b=UdXRAri0+tec/hdfVbNqx36hOGU9oAq3eHriUVPZ4Yh3wyZy2wG9C0RzabNRKOKUdufcGe 9DNjHMzAGHoKNCexXB86CDG7XivEP3Rwu/fDKAcxicFQ7/miJFx0YFTEad/QheVFskEFjh fiykEFj82d0Vdasabp7npTiwPm61pHU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605106418; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=5Dr0+pyBqVK3WLFkrmGnVmo0jFKi8+9WQgJ494/SxHE=; b=Amd18ETlBQR+paU9xX5SikU5yQjgJzoFY03jIdVtE0wMJxh8kUp4e0PLNdfIyKr2x2pMdV CjuHUfmRSjVNwZDGYSzXlpzupIlFryAx+wXSkQdspoj3tuOPjVXSGlyDIXGZvCPt9znoq3 W3JYMlB8ooLDO3FOUOgA9hSxdQqaVyE= 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-572-bF7ocHOgOXK6oeBoGufIsg-1; Wed, 11 Nov 2020 09:53:33 -0500 X-MC-Unique: bF7ocHOgOXK6oeBoGufIsg-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 5093318CB72A; Wed, 11 Nov 2020 14:53:30 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-151.ams2.redhat.com [10.36.114.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6BDD380; Wed, 11 Nov 2020 14:53:23 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Subject: [PATCH v2 0/8] powernv/memtrace: don't abuse memory hot(un)plug infrastructure for memory allocations Date: Wed, 11 Nov 2020 15:53:14 +0100 Message-Id: <20201111145322.15793-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Hocko , Wei Yang , David Hildenbrand , Nicholas Piggin , Michal Hocko , linux-mm@kvack.org, Paul Mackerras , "Aneesh Kumar K.V" , Andrew Morton , linuxppc-dev@lists.ozlabs.org, Rashmica Gupta , Mike Rapoport , Oscar Salvador Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Based on latest linux/master powernv/memtrace is the only in-kernel user that rips out random memory it never added (doesn't own) in order to allocate memory without a linear mapping. Let's stop abusing memory hot(un)plug infrastructure for that - use alloc_contig_pages() for allocating memory and remove the linear mapping manually. The original idea was discussed in: https://lkml.kernel.org/r/48340e96-7e6b-736f-9e23-d3111b915b6e@redhat.com I only tested via QEMU TCG with a single NUMA node- see patch #8 for more details. Error handling and cleanup handling in memtrace code is a mess - that should definitely get cleaned up sooner or later. Once we have __GFP_ZERO support for alloc_contig_pages(), we can drop manual clearing. I added a TODO for now, so this series can go via the powerpc tree - the __GFP_ZERO change is then better suited via the mm tree, along with support for __GFP_ZERO. v1 -> v2: - Tweaks to patch descriptions - "powernv/memtrace: don't leak kernel memory to user space" -- Added. Reported by Michael. - "powernv/memtrace: fix crashing the kernel when enabling concurrently" -- Added, discovered while testing. - "powerpc/mm: protect linear mapping modifications by a mutex" -- Added. Although we currently won't have concurrency, this is cleaner and future-proof. - "powerepc/book3s64/hash: drop WARN_ON in hash__remove_section_mapping" -- Added. Suggested by Oscar - "powernv/memtrace: don't abuse memory hot(un)plug infrastructure for memory allocations" -- Reshuffle the code to make review easier. -- Add a TODO regarding __GFP_ZERO. Adapt to changed page clearing code. -- Use GFP_KERNEL | __GFP_THISNODE | __GFP_NOWARN for allocations. David Hildenbrand (8): powernv/memtrace: don't leak kernel memory to user space powernv/memtrace: fix crashing the kernel when enabling concurrently powerpc/mm: factor out creating/removing linear mapping powerpc/mm: protect linear mapping modifications by a mutex powerpc/mm: print warning in arch_remove_linear_mapping() powerepc/book3s64/hash: drop WARN_ON in hash__remove_section_mapping powerpc/mm: remove linear mapping if __add_pages() fails in arch_add_memory() powernv/memtrace: don't abuse memory hot(un)plug infrastructure for memory allocations arch/powerpc/mm/book3s64/hash_utils.c | 1 - arch/powerpc/mm/mem.c | 53 +++++-- arch/powerpc/platforms/powernv/Kconfig | 8 +- arch/powerpc/platforms/powernv/memtrace.c | 175 ++++++++++------------ include/linux/memory_hotplug.h | 3 + 5 files changed, 125 insertions(+), 115 deletions(-) -- 2.26.2