Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1183576ybh; Thu, 16 Jul 2020 05:39:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwq8Hmu5gitBk6fQ/5/LVQBgJ/dYUC1Ljd1EsMzZNjRxYLYXZSrCLtMps4S+K9jgdhQt/s+ X-Received: by 2002:a05:6402:1777:: with SMTP id da23mr4206504edb.260.1594903161691; Thu, 16 Jul 2020 05:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594903161; cv=none; d=google.com; s=arc-20160816; b=rABLprSKQ1OEOnI4gh9TtxcwtfT1+wL/dC53C8rGMG/ZftUufnfY/GJtmWWf5kenrg Rv3HJ+YRGNvQ3WnjaWGcemerbg6uW/ibHgVIlhBaFl2J3rtekQH0db+f4lAmYrUwkxUj l50U+z7aOuGBftg06aFHJiKJKubht1o3FIjVoOYmW7l+X98w2KAlec49QrH+5cP+gB0f HFvKxmEUjHTsnwOUAlY4slXayLaN1ZCarSVMFLuMVw71zgCw8OOWOEkat0SEPSs9P7pL ZKGPAYa6CwOo7GwHsGX1se986QxLt829VSFC5TU4QqC4dsW706kYRQhLi1jOYcPdRoRq 9SwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=ru4zJshFFLYJCiXj9uDLilOmuhtoAbQImioWFNS7BR0=; b=b9tNDABUpS9nYd5a2sBbqafXFnLCq8QLvX08sNQWt9GbUo0QJ0ZHWVcxn6/o+z5PJv prKrxd8LWobGS2dvtV/KbPI6otbGeNATybTuegyNteuYUt+jwfLtCQQN013w6i271viL aIZqWh1Onlpk1cZmRzaK1zZM7kjNbxtnNAYxlbYXd9Qj2r4d7ETh5jjRxEhS4R6E40Yl 1wGyBMnWaFAahKZFPbCfid2nQao360+/J8bBC3kufyaKTQ09L3Zqa7a52FYk9lcNjnsQ U57MthCUZXUgv+HJ+lOjgVwoRUHuY2B60ls4ijVnR3IjkEpYNDQ6zdibB+fN3TnVAUOm clhg== ARC-Authentication-Results: i=1; mx.google.com; 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 h22si3399213ejf.256.2020.07.16.05.38.58; Thu, 16 Jul 2020 05:39:21 -0700 (PDT) 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; 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 S1728723AbgGPMiV (ORCPT + 99 others); Thu, 16 Jul 2020 08:38:21 -0400 Received: from mx2.suse.de ([195.135.220.15]:35640 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728530AbgGPMiU (ORCPT ); Thu, 16 Jul 2020 08:38:20 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 50EC0B93C; Thu, 16 Jul 2020 12:38:22 +0000 (UTC) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, linux-mm@kvack.org, mike.kravetz@oracle.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v4 00/15] Hwpoison soft-offline rework Date: Thu, 16 Jul 2020 14:37:54 +0200 Message-Id: <20200716123810.25292-1-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, this is a follow-up version on [1]. That version had some flaws wrt. handling hugetlb pages, so this version fixes it. I checked that the case reported by Qian seems to work fine now. Cover letter: This patchset was initially based on Naoya's hwpoison rework [1], so thanks to him for the initial work. I would also like to think Naoya for testing the patchset off-line, and report any issues he found, that was quite helpful. This patchset aims to fix some issues laying in soft-offline handling, but it also takes the chance and takes some further steps to perform cleanups and some refactoring as well. - Motivation: A customer and I were facing an issue were processes were killed after having soft-offlined some of their pages. This should not happen when soft-offlining, as it is meant to be non-disruptive. I was able to reproduce the issue when I stressed the memory + soft offlining pages in the meantime. After debugging the issue, I saw that the problem was that pages were returned back to user-space after having offlined them properly. So, when those pages were faulted in, the fault handler returned VM_FAULT_POISON all the way down to the arch handler, and it simply killed the process. After a further anaylsis, it became clear that the problem was that when kcompactd kicked in to migrate pages over, compaction_alloc callback was handing poisoned pages to the migrate routine. All this could happen because isolate_freepages_block and fast_isolate_freepages just check for the page to be PageBuddy, and since 1) poisoned pages can be part of a higher order page and 2) poisoned pages are also Page Buddy, they can sneak in easily. I also saw some other problems with sawap pages, but I suspected it to be the same sort of problem, so I did not follow that trace. The above refers to soft-offline. But I also saw problems with hard-offline, specially hugetlb corruption, and some other weird stuff. (I could paste the logs) The full explanation refering to the soft-offline case can be found at [2]. - Approach: The taken approach is to contain those pages and never let them hit neither pcplists nor buddy freelists. Only when they are completely out of reach, we flag them as poisoned. A full explanation of this can be found in patch#11 and patch#12 - Outcome: With this patchset, I no longer see the issues with soft-offline. [1] https://lore.kernel.org/linux-mm/1541746035-13408-1-git-send-email-n-horiguchi@ah.jp.nec.com/ [2] https://lore.kernel.org/linux-mm/20190826104144.GA7849@linux/T/#u Naoya Horiguchi (6): mm,hwpoison: cleanup unused PageHuge() check mm, hwpoison: remove recalculating hpage mm,madvise: call soft_offline_page() without MF_COUNT_INCREASED mm,hwpoison-inject: don't pin for hwpoison_filter mm,hwpoison: remove MF_COUNT_INCREASED mm,hwpoison: remove flag argument from soft offline functions Oscar Salvador (9): mm,madvise: Refactor madvise_inject_error mm,hwpoison: Un-export get_hwpoison_page and make it static mm,hwpoison: Kill put_hwpoison_page mm,hwpoison: Unify THP handling for hard and soft offline mm,hwpoison: Rework soft offline for free pages mm,hwpoison: Rework soft offline for in-use pages mm,hwpoison: Refactor soft_offline_huge_page and __soft_offline_page mm,hwpoison: Return 0 if the page is already poisoned in soft-offline mm,hwpoison: introduce MF_MSG_UNSPLIT_THP drivers/base/memory.c | 2 +- include/linux/mm.h | 12 +- include/linux/page-flags.h | 6 +- include/ras/ras_event.h | 3 + mm/hugetlb.c | 60 +++++++- mm/hwpoison-inject.c | 18 +-- mm/madvise.c | 37 ++--- mm/memory-failure.c | 307 +++++++++++++++---------------------- mm/migrate.c | 11 +- mm/page_alloc.c | 70 +++++++-- 10 files changed, 270 insertions(+), 256 deletions(-) -- 2.26.2