From mboxrd@z Thu Jan 1 00:00:00 1970 From: akpm@linux-foundation.org Subject: + mmmadvise-call-soft_offline_page-without-mf_count_increased.patch added to -mm tree Date: Wed, 24 Jun 2020 12:19:26 -0700 Message-ID: <20200624191926.Ob2AB%akpm@linux-foundation.org> Reply-To: linux-kernel@vger.kernel.org Return-path: Received: from mail.kernel.org ([198.145.29.99]:59822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405057AbgFXTT1 (ORCPT ); Wed, 24 Jun 2020 15:19:27 -0400 Sender: mm-commits-owner@vger.kernel.org List-Id: mm-commits@vger.kernel.org To: mm-commits@vger.kernel.org, zeil@yandex-team.ru, tony.luck@intel.com, osalvador@suse.de, mike.kravetz@oracle.com, mhocko@kernel.org, david@redhat.com, dave.hansen@intel.com, aneesh.kumar@linux.vnet.ibm.com, aneesh.kumar@linux.ibm.com, naoya.horiguchi@nec.com The patch titled Subject: mm,madvise: call soft_offline_page() without MF_COUNT_INCREASED has been added to the -mm tree. Its filename is mmmadvise-call-soft_offline_page-without-mf_count_increased.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mmmadvise-call-soft_offline_page-without-mf_count_increased.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mmmadvise-call-soft_offline_page-without-mf_count_increased.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Naoya Horiguchi Subject: mm,madvise: call soft_offline_page() without MF_COUNT_INCREASED The call to get_user_pages_fast is only to get the pointer to a struct page of a given address, pinning it is memory-poisoning handler's job, so drop the refcount grabbed by get_user_pages_fast(). Note that the target page is still pinned after this put_page() because the current process should have refcount from mapping. Link: http://lkml.kernel.org/r/20200624150137.7052-4-nao.horiguchi@gmail.com Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador Cc: "Aneesh Kumar K.V" Cc: Aneesh Kumar K.V Cc: Dave Hansen Cc: David Hildenbrand Cc: Dmitry Yakunin Cc: Michal Hocko Cc: Mike Kravetz Cc: Tony Luck Signed-off-by: Andrew Morton --- mm/madvise.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) --- a/mm/madvise.c~mmmadvise-call-soft_offline_page-without-mf_count_increased +++ a/mm/madvise.c @@ -893,16 +893,24 @@ static int madvise_inject_error(int beha */ size = page_size(compound_head(page)); - if (PageHWPoison(page)) { - put_page(page); + /* + * The get_user_pages_fast() is just to get the pfn of the + * given address, and the refcount has nothing to do with + * what we try to test, so it should be released immediately. + * This is racy but it's intended because the real hardware + * errors could happen at any moment and memory error handlers + * must properly handle the race. + */ + put_page(page); + + if (PageHWPoison(page)) continue; - } if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", pfn, start); - ret = soft_offline_page(pfn, MF_COUNT_INCREASED); + ret = soft_offline_page(pfn, 0); if (ret) return ret; continue; @@ -910,14 +918,6 @@ static int madvise_inject_error(int beha pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", pfn, start);