Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1554284pxu; Sat, 12 Dec 2020 17:31:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwnnKe0BtA9Wx0w/9zkS2OLbDg+4aJ2VXgWRvKd9/LildiTZfDdt+xIy7T3sMqiP/z85So X-Received: by 2002:a50:b742:: with SMTP id g60mr18398381ede.113.1607823102561; Sat, 12 Dec 2020 17:31:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607823102; cv=none; d=google.com; s=arc-20160816; b=b9E38Ffs4/rRfN677R7uF1XsP1yMIkBZOPWlbo1zu40no4OHRku5YJ3rWypXoAgdha OK2L4q+BoJ1Hcdp3eFyNKa8wDRKI0Az4u0CLoFyU8f1t0kGnN4EkX5aL3VukkzqFv2vJ 4fgrC613lpEp4iJI9fEMAxQqrnWoV7P198iIWbuTfesCz5TzkfmlEDHoziC7Gcs5AsFm YV3/PnLsWnTvBZT7FoNGtGSOu71CfA/7+TpJOD+kLAruIXjN5rxS2AW3aTLeD1ZsMu2t qwLV+8ievisgvIYbjSlZB8K4StXwxCqtD57LtZ8s0SerMbPNcyUXfhST0ca+1VME4FGU 4IPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=wM4+TgIt1qy5AvzR8HLrxu1ifc40asavzOXqjbFYbkc=; b=s/airQuqDwIKwO0i4ZEDHLmNl0ESfZUpqjQ56dl9L9erU3fz8Kp/NzDJSW0yqc3yTR L7ZTNykFqKsas8qXnHB0Sa36NKvOS1W8keVfD0+b/yd8SgqiJD5JtL+jwP8JuS9uOIhE kJGIKjsSQBH6yhr3Co+XLMg2rIxwpTR0WEB5jUWcxYY5mRbYETC7h42Hzo+/XFCGmyZk GyBs07FizznTmU9Wdr/3hP41cRbHYSrYnDgHqmJ4o56VAr2tR17n0IAe/e5IimGjgRam 1oUTFUTsPaet6j+fN38S2OW8wKZcmJqYbHvdV0yPJ+KD3SdR8KltRP/VwRR0E+xiKSuy MM1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=a+HUIRjF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz19si8663223ejb.238.2020.12.12.17.31.20; Sat, 12 Dec 2020 17:31:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=a+HUIRjF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389463AbgLKUWk (ORCPT + 99 others); Fri, 11 Dec 2020 15:22:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388074AbgLKUWY (ORCPT ); Fri, 11 Dec 2020 15:22:24 -0500 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4E93C0613D3 for ; Fri, 11 Dec 2020 12:21:43 -0800 (PST) Received: by mail-qk1-x742.google.com with SMTP id 143so9711956qke.10 for ; Fri, 11 Dec 2020 12:21:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=wM4+TgIt1qy5AvzR8HLrxu1ifc40asavzOXqjbFYbkc=; b=a+HUIRjFLUUSLUo/2eD3kC7hFtY5Bysj1lxaE1P9nNU7WySBlKU6F5bM6LJ092gq47 32bs1F3kv6sENBJYz15baCNRpolOJxZvPHEJFpI5vqiHQ7boZvH/QxxbcGx8/5WXzDz+ CfO9VZqtWSEqbdEHcdWejcBmlSokyaY/IyUMCYOvFkWyZ5hR4EfdFAP0zPPvwo76pjh/ oON8wnJjKT/DpkN6h+rcKfHpKMawPW4oUxsf4C/lBgdRQGCq58R+R0SEtTxEHtUCqsj4 R0t5mgFcsorQ4fE7e0CjM6fzZyduhmhQIdahWZEotEDkLhsGmTqbDCklsrAAY9cEQt9l JfAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=wM4+TgIt1qy5AvzR8HLrxu1ifc40asavzOXqjbFYbkc=; b=U9pbkjXcG2o3buVcQobAVaPaiUJjT0zOHr8/ny3XUsmGDhi0DRfKUiC0ie51/sv8Nt AKYwESCCSFhkZFjf+D6EdgExM+F8rgK7byfkkJHHHQ+1tvMZAZqIMtM52X1Nu29zergl SCC/XM4t0yGfLdZcA0mraTEJjb+kWhvdTJC/yW4qOGHPCe2GmPR1WoSF6K6kxekLNTkC 2vBi0zIKPrDW2P6UrtcbaoBNh3R4RxSyQiTJ7L3a+2pEHdHBC+rUqs1fTMZnXJR+kun9 RlFRXH145k8qOVJ5uAiFRFqyiTMXsu2jCSHqpGXIvS/EjXcREQ2nrV36JxiFWQwi+UqF gsqw== X-Gm-Message-State: AOAM530OEvLgXj1MIpR2wdaNc6Bn+m+0y2IC0BFFsTGwIFM+aXXNWokx o2KLCC5/Jt/JjeyxjcJ0oQUzRQ== X-Received: by 2002:a37:6c03:: with SMTP id h3mr18224198qkc.219.1607718102987; Fri, 11 Dec 2020 12:21:42 -0800 (PST) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id y192sm8514455qkb.12.2020.12.11.12.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Dec 2020 12:21:42 -0800 (PST) From: Pavel Tatashin To: pasha.tatashin@soleen.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, vbabka@suse.cz, mhocko@suse.com, david@redhat.com, osalvador@suse.de, dan.j.williams@intel.com, sashal@kernel.org, tyhicks@linux.microsoft.com, iamjoonsoo.kim@lge.com, mike.kravetz@oracle.com, rostedt@goodmis.org, mingo@redhat.com, jgg@ziepe.ca, peterz@infradead.org, mgorman@suse.de, willy@infradead.org, rientjes@google.com, jhubbard@nvidia.com, linux-doc@vger.kernel.org Subject: [PATCH v3 0/6] prohibit pinning pages in ZONE_MOVABLE Date: Fri, 11 Dec 2020 15:21:34 -0500 Message-Id: <20201211202140.396852-1-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changelog --------- v3 - Merged with linux-next, which contains clean-up patch from Jason, therefore this series is reduced by two patches which did the same thing. v2 - Addressed all review comments - Added Reviewed-by's. - Renamed PF_MEMALLOC_NOMOVABLE to PF_MEMALLOC_PIN - Added is_pinnable_page() to check if page can be longterm pinned - Fixed gup fast path by checking is_in_pinnable_zone() - rename cma_page_list to movable_page_list - add a admin-guide note about handling pinned pages in ZONE_MOVABLE, updated caveat about pinned pages from linux/mmzone.h - Move current_gfp_context() to fast-path --------- When page is pinned it cannot be moved and its physical address stays the same until pages is unpinned. This is useful functionality to allows userland to implementation DMA access. For example, it is used by vfio in vfio_pin_pages(). However, this functionality breaks memory hotplug/hotremove assumptions that pages in ZONE_MOVABLE can always be migrated. This patch series fixes this issue by forcing new allocations during page pinning to omit ZONE_MOVABLE, and also to migrate any existing pages from ZONE_MOVABLE during pinning. It uses the same scheme logic that is currently used by CMA, and extends the functionality for all allocations. For more information read the discussion [1] about this problem. [1] https://lore.kernel.org/lkml/CA+CK2bBffHBxjmb9jmSKacm0fJMinyt3Nhk8Nx6iudcQSj80_w@mail.gmail.com Previous versions: v1 https://lore.kernel.org/lkml/20201202052330.474592-1-pasha.tatashin@soleen.com v2 https://lore.kernel.org/lkml/20201210004335.64634-1-pasha.tatashin@soleen.com Pavel Tatashin (6): mm/gup: don't pin migrated cma pages in movable zone mm cma: rename PF_MEMALLOC_NOCMA to PF_MEMALLOC_PIN mm: apply per-task gfp constraints in fast path mm: honor PF_MEMALLOC_PIN for all movable pages mm/gup: migrate pinned pages out of movable zone memory-hotplug.rst: add a note about ZONE_MOVABLE and page pinning .../admin-guide/mm/memory-hotplug.rst | 9 +++ include/linux/migrate.h | 1 + include/linux/mm.h | 11 +++ include/linux/mmzone.h | 11 ++- include/linux/sched.h | 2 +- include/linux/sched/mm.h | 27 +++---- include/trace/events/migrate.h | 3 +- mm/gup.c | 72 ++++++++----------- mm/hugetlb.c | 4 +- mm/page_alloc.c | 32 ++++----- mm/vmscan.c | 10 +-- 11 files changed, 95 insertions(+), 87 deletions(-) -- 2.25.1