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 8D62EC5517A for ; Wed, 11 Nov 2020 14:53:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F14B321D7F for ; Wed, 11 Nov 2020 14:53:38 +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="Ir79xG2y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F14B321D7F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 036556B0071; Wed, 11 Nov 2020 09:53:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F2AFF6B0080; Wed, 11 Nov 2020 09:53:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E67446B0081; Wed, 11 Nov 2020 09:53:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id BB9596B0071 for ; Wed, 11 Nov 2020 09:53:37 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 50EDC8249980 for ; Wed, 11 Nov 2020 14:53:37 +0000 (UTC) X-FDA: 77472431274.01.swim16_0e180db272fe Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 0D52710045BF3 for ; Wed, 11 Nov 2020 14:53:37 +0000 (UTC) X-HE-Tag: swim16_0e180db272fe X-Filterd-Recvd-Size: 5109 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Wed, 11 Nov 2020 14:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605106415; 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=Ir79xG2yLD/riet8TMtKd95HoDk06HGGenoaUxLx8DsMfH+XQF5eAZDDck/V9FBWXOicCC LmqmYWazE1izlClcyGj530fbHGh6/V4MluvayQajm3oRPCoohEM7mEU/18C6wtxiGVCt9a MfpCfAiOVNfXMfT+S7H/8r+RKJHVnBE= 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 Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, David Hildenbrand , Andrew Morton , "Aneesh Kumar K.V" , Benjamin Herrenschmidt , Michael Ellerman , Michal Hocko , Michal Hocko , Mike Rapoport , Nicholas Piggin , Oscar Salvador , Paul Mackerras , Rashmica Gupta , Wei Yang 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 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Content-Transfer-Encoding: quoted-printable 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: 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.co= m 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_ZE= RO 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 a= nd 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(-) --=20 2.26.2