From patchwork Wed Jun 24 15:01:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623375 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0F53560D for ; Wed, 24 Jun 2020 15:02:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFF0D206C0 for ; Wed, 24 Jun 2020 15:02:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UwaotPoi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFF0D206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0809F6B0010; Wed, 24 Jun 2020 11:02:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0580E6B0022; Wed, 24 Jun 2020 11:02:46 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB00F6B0023; Wed, 24 Jun 2020 11:02:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id D293D6B0010 for ; Wed, 24 Jun 2020 11:02:45 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 87A40181AC9C6 for ; Wed, 24 Jun 2020 15:02:45 +0000 (UTC) X-FDA: 76964422290.19.sign88_1f1003926e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id B01231AD809 for ; Wed, 24 Jun 2020 15:01:54 +0000 (UTC) X-Spam-Summary: 1,0,0,6431b0ec9a101500,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:355:379:541:800:960:968:973:981:982:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2899:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3871:4321:5007:6261:6653:7576:8957:9413:10004:11026:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12740:12895:12986:13069:13311:13357:14096:14181:14384:14394:14721:21060:21080:21222:21444:21627:21666:22119:30012:30046:30054:30070:30079,0,RBL:209.85.216.67:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04ygq548x6ct459c9r5we85y6ewaqyc6hxipd4sz67m49fhzxofcn4ctyu4cho7.m7hym3f9i9h6c7nfgtohscop19ro5fsmz8sbt3b9i8udb8ofhakkmxooy1n4p5r.6-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: sign88_1f1003926e45 X-Filterd-Recvd-Size: 4367 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:01:46 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id jz3so1279378pjb.0 for ; Wed, 24 Jun 2020 08:01:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lCfhSpDjLg0oQm41kWMqoMza5V2vl2PVe0Cy2zdpUs4=; b=UwaotPoi71Q37vlpe0idrCVUeedFZnNJi7hm4BN/zg+fqUR/nfv8+x/cMKGbRswW6K nDRh8yun2BNbgOmjhg2BmgGXGsFf5M2ZAr4Kl9dTIAVodNCsqmTIEXtEURu/4SURPh14 vqVq7YW5Ctj0JIxt6FtaNcx5DQp9AmkIHpEXWmAX7iZZ9fxUbVkfo9ptpLZS1+zqe5z0 FUvFEpMYMtvuni7uuKF2E7BLXluQ8BAoYlp02MLUDRykv138y8b9a+Q234TNYXVq20NG n7utb0dCNuvTssYtKNY2gC5CCPvqqsCksE3B0/Lj80ocPbu+XsGOH/sWKJ7rrlim8cFS 62Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lCfhSpDjLg0oQm41kWMqoMza5V2vl2PVe0Cy2zdpUs4=; b=MmVTYSCdNmVUk2mRLBrY7mLj2QP9slFN6PZvDybm+btd0zMH6NvkeGh9yNZHYVMTd3 1nz5BYDaDv5svsHXNusN2aEhB4HdgmVfqkwqDvh7H+4WgIXjRNaho+dkwbjXhNGIoAaX Mvbc6t/KT28Jmftu+ejyNb0/KUO3wAaBXaZXGc1mq0tZloLFVViJ/Wrie54jmriaWq0m C7DTK7XRdjBp8RCY9pPblPGb1R8QHQbghsMbr1FaPyq+QFzPpgDnBj37yWFvbyhgZrSh vE7N2xXCUi19GTuSTDXY1deJ0r5VcKvcBTKSReg6vIBBQP4sIX9sRsimtRE/OIBNAqJB ivRQ== X-Gm-Message-State: AOAM530Gg5txxOfm73fBWgb/fCLY78neGfZ73oYI+kfIswQXPoh5EAcB JmBQ5m0+rWWB2VG4aabPM2MKbKhY5g== X-Google-Smtp-Source: ABdhPJw1QP92/ouJDzFZIrN4onjqHXS1nPeUFAid6e2y7e70YPrRcwv0Aq6U4DIjcbRurGP8vn/3eA== X-Received: by 2002:a17:902:d207:: with SMTP id t7mr12891961ply.251.1593010905510; Wed, 24 Jun 2020 08:01:45 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:01:45 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 01/15] mm,hwpoison: cleanup unused PageHuge() check Date: Wed, 24 Jun 2020 15:01:23 +0000 Message-Id: <20200624150137.7052-2-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: B01231AD809 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: From: Naoya Horiguchi Drop the PageHuge check, which is dead code since memory_failure() forks into memory_failure_hugetlb() for hugetlb pages. memory_failure() and memory_failure_hugetlb() shares some functions like hwpoison_user_mappings() and identify_page_state(), so they should properly handle 4kB page, thp, and hugetlb. Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador Reviewed-by: Mike Kravetz --- changelog v2 -> v3: - add description about shared logic b/w hugetlb and non-hugetlb path. --- mm/memory-failure.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index 47b8ccb1fb9b..e5d0c14c2332 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -1382,10 +1382,7 @@ int memory_failure(unsigned long pfn, int flags) * page_remove_rmap() in try_to_unmap_one(). So to determine page status * correctly, we save a copy of the page flags at this time. */ - if (PageHuge(p)) - page_flags = hpage->flags; - else - page_flags = p->flags; + page_flags = p->flags; /* * unpoison always clear PG_hwpoison inside page lock From patchwork Wed Jun 24 15:01:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623369 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C2DB60D for ; Wed, 24 Jun 2020 15:02:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D5C31206EB for ; Wed, 24 Jun 2020 15:02:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EQ5vFoRh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5C31206EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AB9D96B000A; Wed, 24 Jun 2020 11:02:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A8F9B6B000C; Wed, 24 Jun 2020 11:02:20 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 97F576B000D; Wed, 24 Jun 2020 11:02:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 80CCA6B000A for ; Wed, 24 Jun 2020 11:02:20 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2456F9435 for ; Wed, 24 Jun 2020 15:02:20 +0000 (UTC) X-FDA: 76964421240.29.dust69_2a13a7f26e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 61F2118088030 for ; Wed, 24 Jun 2020 15:01:56 +0000 (UTC) X-Spam-Summary: 1,0,0,191f4fe7b2928243,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1431:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2895:2899:3138:3139:3140:3141:3142:3352:3865:3866:3867:3870:3871:4321:5007:6119:6261:6653:7576:7903:9413:10004:11026:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:13069:13311:13357:14096:14181:14384:14394:14721:21060:21080:21444:21451:21627:21666:21795:22119:30051:30054:30070,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04ygats4f1jieod9rnun8kikdghfaocedmyrn68ojbbp1be9p3nuuftt4jft7cp.mnxx9sk8a1ks55dz3i1g9bgjd7c4nojp8q81io578p3shyp87z9bg7ua5f135qy.k-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: dust69_2a13a7f26e45 X-Filterd-Recvd-Size: 4397 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:01:49 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id i4so1273957pjd.0 for ; Wed, 24 Jun 2020 08:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=44MI/Xaebogle3byf0K/hbjxI15crYL5kj8QhCCzmQA=; b=EQ5vFoRhF+Dxmx9u/l3YuFN2NQ/we8WRaTM7Lbb+HasxiRQIshvNWwzDn2TRo6H5h8 NJFxR9veJODp4lBLCyrYVN+Cya1oe+8ppdH1N2LYrhOVXuXbQgNH/UIampBwrC1S9jrw kbjWyxO0XJ7ocBMiWBt5cFImGcAQYU/yrdeqzbGPidbceWfEdNLUzOPJh9wXOiTTzi/I OQ89WCvmCYd9I7AxgSoVLgcBrLyFXjBV0LSD2/M7uyCz3zZa/mrnn7tZPekS5UT2JXU0 3diAQnd8ZB5E0ZhFmPYz8tDI8Utwg3ZPtvYhtZkcq8Kfu8viHjXwsgai4ic7ZyG4y9xe P6/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=44MI/Xaebogle3byf0K/hbjxI15crYL5kj8QhCCzmQA=; b=mnyXp7wOUPZhGqaZcw/Sfnz3BH0Z0JEUvm0NhjgXzJPFtX+Jc/SMq01G2fcSgWdTzx P+uX14tPA/+tYMHQHS4LgkOew5aMOzMXRpaOtuTAT0g6svkAJG5rju4Sr7jxYK2BaAMZ Dd4GTGHsRwWdakZkVQPX3PhPEkpMd20Ey5oqHjHPRqsLv/OQZ1QJXWGOITDEkYmw7OZQ 25DA51urOKe52Zt2TOeEAjCYFO9Z3/RBVAwSXN5mU7AP9q1dNT+BPGbZDBVbaU7rCBOK qm4NZDoVuWCeM02DCT0yTB4EjVdds4qZWgN53wZwkK49SgoxtHM2UOKUD/mK6IfWuEuA XnYw== X-Gm-Message-State: AOAM530tuKPx9d74jVyZGh0aFe3RDhoZoAxDq44budAFppazS99tYLHy eDb5dFjNjYFtvGD0sdw5yDcj93yhJg== X-Google-Smtp-Source: ABdhPJyHPrGdh1QNyO3qvNQ7njQOvx6xQmbxOT6KvZfUmzZ8Kl5sDHMCYDfiH2fKVFHMhvkmzWiBQA== X-Received: by 2002:a17:90a:fd90:: with SMTP id cx16mr2508625pjb.42.1593010908500; Wed, 24 Jun 2020 08:01:48 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.01.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:01:48 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 02/15] mm, hwpoison: remove recalculating hpage Date: Wed, 24 Jun 2020 15:01:24 +0000 Message-Id: <20200624150137.7052-3-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 61F2118088030 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: From: Naoya Horiguchi hpage is never used after try_to_split_thp_page() in memory_failure(), so we don't have to update hpage. So let's not recalculate/use hpage. Suggested-by: "Aneesh Kumar K.V" Signed-off-by: Naoya Horiguchi Reviewed-by: Mike Kravetz --- mm/memory-failure.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index e5d0c14c2332..d2d6010764e7 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -1342,7 +1342,6 @@ int memory_failure(unsigned long pfn, int flags) } unlock_page(p); VM_BUG_ON_PAGE(!page_count(p), p); - hpage = compound_head(p); } /* @@ -1414,11 +1413,8 @@ int memory_failure(unsigned long pfn, int flags) /* * Now take care of user space mappings. * Abort on fail: __delete_from_page_cache() assumes unmapped page. - * - * When the raw error page is thp tail page, hpage points to the raw - * page after thp split. */ - if (!hwpoison_user_mappings(p, pfn, flags, &hpage)) { + if (!hwpoison_user_mappings(p, pfn, flags, &p)) { action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); res = -EBUSY; goto out; From patchwork Wed Jun 24 15:01:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623371 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F3FA60D for ; Wed, 24 Jun 2020 15:02:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 42E1B206C0 for ; Wed, 24 Jun 2020 15:02:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZbkXzDYE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42E1B206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6C14F6B000C; Wed, 24 Jun 2020 11:02:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 671926B000D; Wed, 24 Jun 2020 11:02:31 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 588766B000E; Wed, 24 Jun 2020 11:02:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0115.hostedemail.com [216.40.44.115]) by kanga.kvack.org (Postfix) with ESMTP id 437C66B000C for ; Wed, 24 Jun 2020 11:02:31 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 08E663499 for ; Wed, 24 Jun 2020 15:02:31 +0000 (UTC) X-FDA: 76964421702.20.group14_540e6f926e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 20FAD180C01A8 for ; Wed, 24 Jun 2020 15:01:58 +0000 (UTC) X-Spam-Summary: 30,2,0,db2c8dd7cb56a9d1,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:2898:2899:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:4321:4641:5007:6119:6261:6653:7576:7903:8603:8660:9413:9592:10010:11026:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:12986:13148:13161:13180:13229:13230:13255:14181:14394:14721:21060:21080:21212:21444:21627:21666:21740:21939:21987:21990:22119:30003:30054:30070:30091,0,RBL:209.85.210.196:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yfihe85rxep9pgjkd8zg77imgtfypu793m87189scyqewyuow151jihspduec.x1a5ffg61gc7msn3qw31ua8esqt1bxbxdzmzjw16buzua4rkojsygcozeefntzr.q-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:1:0,LFtime:28,LUA_SUMMARY:none X-HE-Tag: group14_540e6f926e45 X-Filterd-Recvd-Size: 5323 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:01:53 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id q17so1270849pfu.8 for ; Wed, 24 Jun 2020 08:01:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FEJYjJlKBMyCMGijANDJfuAtwxDZBaJxFe8PT9k9lOo=; b=ZbkXzDYEzJAUOuoSuEPzDu3T3s2ANCIzdd/mnQhx9cIhkexxmXPyqUiKUS0a04gkLc ClQ0zVIPoY4JTr7mLz6mRIb8GiZoAVbF9I7BvuHTjg+TlIaSj0diBgyscF9vB0ylPykx kwqNGGo2RxBMxs2ql8yN1S/VO248AAynV4rRRkp6mPFiGVsnLhSME7GPaDAgnpzM22Ig dxYphPIbWdhtdDe42x2jNvAUP5hAyT9KuNQvqG2pJ8Br08sS0MHuW1mWtUoYg5PfnHS3 MDa6suSQy8rwoX8axAXr4u5hNRw3Q5EcIkgi6fdkxsfQ1BZCAh6j39GhJSQLsLV+4IaX ellA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FEJYjJlKBMyCMGijANDJfuAtwxDZBaJxFe8PT9k9lOo=; b=niz7eg4mHfhKCxAEDonhMtwzgzvmDBOSNeTVQOru/kGsK4Pgy/v3RlsAnN0kbbSS7U eGzU3Lq+y2TMaftdWs6ENAtqof1P568E5ac8yfi8AWDZTdfxkvm6jeu3VSxIDk6AhYHt xdupqnodVZ2iUUO+S32j/uXDgnmCwG/Ux4LbOFOwPBvHjI8aMeTTR88bkNW0qdo7epwx Ia6yS/a05049buHr3MU1mwE+VzSZBBq7Ro2z1hT8EPGE0wehOUqSaxemzQgl6U/tBdBO sXmQiWuDevNic3OChXHBKxjCEwkcd7gnbknfPvV+WfDSuJqqcycPg2UTjGgmNXGLMQNR AMOg== X-Gm-Message-State: AOAM530zndsId3olCBTNnEyZBrrq+zNR77JxzXZL5NHg3A0ZCaj8f88o PqpKzSzmBpr8SOsVT41aNTOszpy9Lg== X-Google-Smtp-Source: ABdhPJwRW8kdDe1v0yNB7iBTcXkFJNL6srZLU4fAx0l+FGJaNBYFg+WuLETuG1PxD12B9E7UFzlNAA== X-Received: by 2002:aa7:8147:: with SMTP id d7mr8105744pfn.29.1593010911771; Wed, 24 Jun 2020 08:01:51 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:01:51 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 03/15] mm,madvise: call soft_offline_page() without MF_COUNT_INCREASED Date: Wed, 24 Jun 2020 15:01:25 +0000 Message-Id: <20200624150137.7052-4-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 20FAD180C01A8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: From: Naoya Horiguchi 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. Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador --- mm/madvise.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/madvise.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c index dd1d43cf026d..275b08edd428 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/madvise.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c @@ -893,16 +893,24 @@ static int madvise_inject_error(int behavior, */ 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 behavior, pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", pfn, start); - - /* - * Drop the page reference taken by get_user_pages_fast(). In - * the absence of MF_COUNT_INCREASED the memory_failure() - * routine is responsible for pinning the page to prevent it - * from being released back to the page allocator. - */ - put_page(page); ret = memory_failure(pfn, 0); if (ret) return ret; From patchwork Wed Jun 24 15:01:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623395 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A7BB60D for ; Wed, 24 Jun 2020 15:03:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1741C206C0 for ; Wed, 24 Jun 2020 15:03:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OlUun5E3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1741C206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DF0456B0027; Wed, 24 Jun 2020 11:03:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DC4AA6B0028; Wed, 24 Jun 2020 11:03:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8AD16B0029; Wed, 24 Jun 2020 11:03:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0086.hostedemail.com [216.40.44.86]) by kanga.kvack.org (Postfix) with ESMTP id B2CD76B0027 for ; Wed, 24 Jun 2020 11:03:26 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 726761802799B for ; Wed, 24 Jun 2020 15:03:26 +0000 (UTC) X-FDA: 76964424012.26.wax00_5a0cc5926e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 03922180192E2 for ; Wed, 24 Jun 2020 15:02:01 +0000 (UTC) X-Spam-Summary: 1,0,0,7d082b372f68e54c,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:968:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2898:2899:3138:3139:3140:3141:3142:3352:3876:3877:4321:5007:6114:6119:6261:6642:6653:7576:7903:8603:9413:9592:10004:11026:11473:11658:11914:12043:12114:12297:12438:12517:12519:12555:12679:12740:12895:13069:13311:13357:14181:14384:14394:14721:21060:21080:21444:21627:21666:21990:22119:30003:30054:30070,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yfgsqwf8h7asosmwg5jmxkourfaoc744tr5531hkj8ceqg15igczcjz4twad1.xixms5ugue4hbde93mhj5nom7uw1m9rnmtfhqkot5tkheppgcdt9hh3bbddcqm7.c-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: wax00_5a0cc5926e45 X-Filterd-Recvd-Size: 4693 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:01:56 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id r18so1531879pgk.11 for ; Wed, 24 Jun 2020 08:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8PwurQU1NxfpMHJph1B1p7tgGvKbCO2GLa0tif4yXmY=; b=OlUun5E3PI4k9fogy7yVJiNq+TrLqHRnF/eCqpsxsTKrWCCHAkjh99qm8Kji4aD2gz KHzGjJmD5OaGQ/wF2rZ0iHiPc4z3oOuPThTrnL54c1Pn16OfcWOlGTv6GgToadt6HEW3 IPPESdDzY/Y8HrXQ55n4wc1scWF08vao/QkxZ8cUtcJNSZ3OGyq01R2sVgtKEGeUZat3 3269OGDWCJOyXGceEmtJd/CQqeu5PhtHTmYMqoke9YDN6yAb/WTsK6KTPkqq2klAY3ci ejtgjnMSjft5/g5uE2QYiHq3Nxd/rsLxKVMBS/tsX4chYx8Ol5YEISRvXV2kKdA4bBzZ S30g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8PwurQU1NxfpMHJph1B1p7tgGvKbCO2GLa0tif4yXmY=; b=MvmzdV6uKgKjQQlNYKcC1IqM52slync/UaPXGIU/l1Fg16J9+QwP0oEht95C+onYoZ vKQOd/8HOW5JbZN+cD655MGcE0V6q9F3tGjSTfVVmT5X96+jVzBc0/g+VjncTupYc6vP ZrAu5Y11H8FaTFFgyDMvHpuibxfPnDyjQLKYzyd8Q3W8CQD9f6gAOHb2ft//eiUl6Mm7 uh+IB/Y33vCnJ37SAWj/fvyLiQkodcFg5LTnJErYOteF9uvNm8AdCJqUuV43N6r++NZC 5imgMjVgkZF3kEKSfEplQNbCrn4Mn8hB51y78+f1ApZnB+7ZTbfFas9Q8PLsDKRcCUYn ydKw== X-Gm-Message-State: AOAM5302yfYZg4rj90f28qOr/2UcJsAn/YdVLJnUBg203OPHeP/oKDsz UUvn03Zr7rXsd7auPmiib+vEpC5wbw== X-Google-Smtp-Source: ABdhPJy3MaesTnbKm6iBd8AhiEdgYeuKwEA3AyCjJp2Ekr7kLhIMvv7gmu1/KH+Vc+k2Wa4yMwId2A== X-Received: by 2002:a65:6710:: with SMTP id u16mr16022611pgf.45.1593010914695; Wed, 24 Jun 2020 08:01:54 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.01.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:01:54 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 04/15] mm,madvise: Refactor madvise_inject_error Date: Wed, 24 Jun 2020 15:01:26 +0000 Message-Id: <20200624150137.7052-5-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 03922180192E2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: From: Oscar Salvador Make a proper if-else condition for {hard,soft}-offline. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- mm/madvise.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/madvise.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c index 275b08edd428..bee1f4ac70d6 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/madvise.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c @@ -869,16 +869,15 @@ static long madvise_remove(struct vm_area_struct *vma, static int madvise_inject_error(int behavior, unsigned long start, unsigned long end) { - struct page *page; struct zone *zone; unsigned long size; if (!capable(CAP_SYS_ADMIN)) return -EPERM; - for (; start < end; start += size) { unsigned long pfn; + struct page *page; int ret; ret = get_user_pages_fast(start, 1, 0, &page); @@ -908,17 +907,14 @@ static int madvise_inject_error(int behavior, if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", - pfn, start); - + pfn, start); ret = soft_offline_page(pfn, 0); - if (ret) - return ret; - continue; + } else { + pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", + pfn, start); + ret = memory_failure(pfn, 0); } - pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", - pfn, start); - ret = memory_failure(pfn, 0); if (ret) return ret; } From patchwork Wed Jun 24 15:01:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623373 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5040160D for ; Wed, 24 Jun 2020 15:02:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1E0D12076E for ; Wed, 24 Jun 2020 15:02:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SMN95lFx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E0D12076E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 22EA36B000D; Wed, 24 Jun 2020 11:02:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 203E96B000E; Wed, 24 Jun 2020 11:02:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 119DA6B0010; Wed, 24 Jun 2020 11:02:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id EB3216B000D for ; Wed, 24 Jun 2020 11:02:39 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9485214510 for ; Wed, 24 Jun 2020 15:02:39 +0000 (UTC) X-FDA: 76964422038.20.cry15_151378b26e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 7F9AE1801915B for ; Wed, 24 Jun 2020 15:02:03 +0000 (UTC) X-Spam-Summary: 1,0,0,c990a1f7ca74ecdf,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:966:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2693:2899:3138:3139:3140:3141:3142:3353:3865:3867:3872:3874:4321:4385:5007:6119:6261:6653:7576:7903:8957:9413:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12740:12895:13069:13311:13357:14181:14384:14394:14721:21060:21080:21094:21323:21444:21451:21627:21666:21990:22119:30054:30070,0,RBL:209.85.210.193:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yf9sb8ed1skjaea7er33i8unfxfocopn7ha4wme1m89uyxaq7zikugfhmsrjo.siykxgt343d1xbofgdyxuugkpkfaq9tueberpw5ixuritegs3mz4aamgjszp9c6.h-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:36,LUA_SUMMARY:none X-HE-Tag: cry15_151378b26e45 X-Filterd-Recvd-Size: 4987 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:01:59 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id j1so1281490pfe.4 for ; Wed, 24 Jun 2020 08:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vGo//y2piUItDtCt+d69yjROMahecLhJLYlxuCdPjdw=; b=SMN95lFx/w+d9J9q5fXpWkMsl0nkfj3ahdWd28iH1Ej/dL3bnERwMHyy5qBJbdrZf2 TgTmvvBIpqABHJxq5+W9AbgRwEShymOKxVDS4wnRWAc2DiTu2w06VUWp3C+C/waieroE pS/xnD56tSFnRmyV30RS1PF1NjqjwcLUNX8PBQ6A6RFxzTYi47CEunCvUfliYKDmAjAv PH5cMk5eD6anBAeNV1OYRdBei0IF3DS11++j797nnqxnuzZiO33wU8t2Yhsgsx7aUwY2 xOO2H3X7tbqSCdc5x8Imoi4zbnlE10C+FBk3DBxKKUwdtSZqLeBP2zSrAR/iYsOpa9VS 8Z/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vGo//y2piUItDtCt+d69yjROMahecLhJLYlxuCdPjdw=; b=rrKN1Che4s7syDJkLX7yVyIQlaviBRllJCTHNlwig4q8TrcUzSiA7OMX3Ij0Vi5wK/ 8GmnDmLsp8Jm7stIxSHxSnnf0fKEHS2DCZjj9f0oXjKoazEClQzuDoj18zsxm5bHYm81 fn4Gk6DlLr45tTkdLfqc3NDhQR8ruEg0NNSMdFuEQ9SQ4na8sBBaN3m/zpQs7ZwXvw3w n3z8a+m+EtnJRCpkYIRsNAwfMF6wncS0KbEM/lMhTvEAQNZ2NbocNMHOEr3jlsnXT8dy svrOnH+w1YWiia8ZhymFD+M6a/0xdvqJOyopa+aQu/w5i72HLr0wcph5R9tS3Hh0671Q hqxw== X-Gm-Message-State: AOAM532P1ZBek+Quk7RyfdDH9mvDP01OhxczYdunAm/IWEDye3YQBptP Jj1ZZQ2ANHlT5+Aq56hhzRzCe+Z6ag== X-Google-Smtp-Source: ABdhPJyib86xuv+4R1hRolRyZfMpndmPbyGA55cTpUqee4JUp+zFt3OIJAUnQOLHWPzxS4jINtGdFQ== X-Received: by 2002:a63:fc1f:: with SMTP id j31mr22657214pgi.104.1593010917772; Wed, 24 Jun 2020 08:01:57 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:01:57 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/15] mm,hwpoison-inject: don't pin for hwpoison_filter Date: Wed, 24 Jun 2020 15:01:27 +0000 Message-Id: <20200624150137.7052-6-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 7F9AE1801915B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: From: Naoya Horiguchi Another memory error injection interface debugfs:hwpoison/corrupt-pfn also takes bogus refcount for hwpoison_filter(). It's justified because this does a coarse filter, expecting that memory_failure() redoes the check for sure. Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador --- mm/hwpoison-inject.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/hwpoison-inject.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/hwpoison-inject.c index e488876b168a..1ae1ebc2b9b1 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/hwpoison-inject.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/hwpoison-inject.c @@ -26,11 +26,6 @@ static int hwpoison_inject(void *data, u64 val) p = pfn_to_page(pfn); hpage = compound_head(p); - /* - * This implies unable to support free buddy pages. - */ - if (!get_hwpoison_page(p)) - return 0; if (!hwpoison_filter_enable) goto inject; @@ -40,23 +35,20 @@ static int hwpoison_inject(void *data, u64 val) * This implies unable to support non-LRU pages. */ if (!PageLRU(hpage) && !PageHuge(p)) - goto put_out; + return 0; /* - * do a racy check with elevated page count, to make sure PG_hwpoison - * will only be set for the targeted owner (or on a free page). + * do a racy check to make sure PG_hwpoison will only be set for + * the targeted owner (or on a free page). * memory_failure() will redo the check reliably inside page lock. */ err = hwpoison_filter(hpage); if (err) - goto put_out; + return 0; inject: pr_info("Injecting memory failure at pfn %#lx\n", pfn); - return memory_failure(pfn, MF_COUNT_INCREASED); -put_out: - put_hwpoison_page(p); - return 0; + return memory_failure(pfn, 0); } static int hwpoison_unpoison(void *data, u64 val) From patchwork Wed Jun 24 15:01:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623389 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B606E60D for ; Wed, 24 Jun 2020 15:03:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8338B206C0 for ; Wed, 24 Jun 2020 15:03:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="q+doV4+Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8338B206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 588F16B0025; Wed, 24 Jun 2020 11:03:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 538CD6B0026; Wed, 24 Jun 2020 11:03:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 426DC6B0027; Wed, 24 Jun 2020 11:03:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 289166B0025 for ; Wed, 24 Jun 2020 11:03:18 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DDAC4824559C for ; Wed, 24 Jun 2020 15:03:17 +0000 (UTC) X-FDA: 76964423634.16.goose47_4010d7d26e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 9EE3A1004F843 for ; Wed, 24 Jun 2020 15:02:08 +0000 (UTC) X-Spam-Summary: 1,0,0,02be479870b2282f,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2899:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:3871:3872:3874:4321:5007:6261:6653:7576:9413:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12740:12895:13069:13311:13357:14096:14181:14384:14394:14721:21060:21080:21444:21451:21627:21666:21795:21990:22119:30012:30051:30054,0,RBL:209.85.216.67:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04y8zci6hedj7d6jte1gj6cazrjawycdqdruxjejhi169dcbo4tnstxxzqzejmp.8qsjpahpnpreucy4cefdwx3jd3mafawiugtcqz64sa8p94ssq9om4bp4qkqb5k4.r-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: goose47_4010d7d26e45 X-Filterd-Recvd-Size: 4959 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:02:01 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id u8so1271578pje.4 for ; Wed, 24 Jun 2020 08:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wi0jvksoTHpVyCfm1g7AC1LGQmraHN9CrSpvP+vNrxQ=; b=q+doV4+QJo4SQbToZ6CFts6JlJmwHSih6rFDYKWnzMwT2ismKWonlG1ioACjQG9y2T WuQ1tuzvxTkHA5eGy8u6zdJFuYmdlJvOuRNbEuqLQqcJEVLdkT+bFHNrKYP3Kdsn+WvJ 7wR9eiuaAawdmty7se0A2foSPz2LnWVpq7sKy0oWa8tSziNaDqOIiN/YX5deP4ffPwhf DYpP/52GEq8QICE5TbvKca7hr7qUQuQU67KfplMVYPkNsTazsIy78nC+Ie2rznB79z0R 6/QWNKU/jKzvg2zqP1B45GnpOEIfh8feOfehXs7tuYHSG3yuU+MfPVmW7i8UQu2mL5Q4 8W8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wi0jvksoTHpVyCfm1g7AC1LGQmraHN9CrSpvP+vNrxQ=; b=Za/HUQlfO2bqsCMegbEfBpW3Q6kxc/OdJaay8Vtnwj1JmQ18gntG6nQz9xi2Gas4pJ Vbvk3oagG3sbWHW2QHqyRdTAwIyVEvMdP5V/mlzsLLXRKVSwTGMTuduGxS/CauyUUa2o l8XtKFnCSoJCcsxTpmYpj+JOMTkV0gWrTj1RfQpla9FY9GqNRVLcZoR246ySe0G8oyRr /TGIWXYFCEDeVwPGKCenZ6Ag4IMUUuaYv18mcCwlnAn3uRCKFvD71cduA2BW64ROgzoL 8jeD1vYjjnfIrEGjYNCQKjmg0whhkg1D6A1QaS58A1hZuPuQjOOm5mWhSAcTod02aRAI U9VA== X-Gm-Message-State: AOAM532R2L3edQFTggPHrsvMRuyupz4PdMs/xCA/hGZsaxO5gUpkLn7G PJT4KcITnrQjx2xPjHUsNzuKF1Xh0g== X-Google-Smtp-Source: ABdhPJycIQtUBi2ck6YMbwEqrTTpRgSmkaqsBpcn8fO7eaJF9vdBD7QAFHcvomHd6q/iBO+H84EXpg== X-Received: by 2002:a17:902:326:: with SMTP id 35mr28823660pld.301.1593010920918; Wed, 24 Jun 2020 08:02:00 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:02:00 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 06/15] mm,hwpoison: Un-export get_hwpoison_page and make it static Date: Wed, 24 Jun 2020 15:01:28 +0000 Message-Id: <20200624150137.7052-7-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 9EE3A1004F843 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: From: Oscar Salvador Since get_hwpoison_page is only used in memory-failure code now, let us un-export it and make it private to that code. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- include/linux/mm.h | 1 - mm/memory-failure.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/include/linux/mm.h v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/mm.h index e6ff54a7b284..050e9cffc2ea 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/include/linux/mm.h +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/mm.h @@ -2995,7 +2995,6 @@ extern int memory_failure(unsigned long pfn, int flags); extern void memory_failure_queue(unsigned long pfn, int flags); extern void memory_failure_queue_kick(int cpu); extern int unpoison_memory(unsigned long pfn); -extern int get_hwpoison_page(struct page *page); #define put_hwpoison_page(page) put_page(page) extern int sysctl_memory_failure_early_kill; extern int sysctl_memory_failure_recovery; diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index d2d6010764e7..48feb45047f7 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -925,7 +925,7 @@ static int page_action(struct page_state *ps, struct page *p, * Return: return 0 if failed to grab the refcount, otherwise true (some * non-zero value.) */ -int get_hwpoison_page(struct page *page) +static int get_hwpoison_page(struct page *page) { struct page *head = compound_head(page); @@ -954,7 +954,6 @@ int get_hwpoison_page(struct page *page) return 0; } -EXPORT_SYMBOL_GPL(get_hwpoison_page); /* * Do all that is necessary to remove user space mappings. Unmap From patchwork Wed Jun 24 15:01:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623397 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9551960D for ; Wed, 24 Jun 2020 15:03:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 54CFD206C0 for ; Wed, 24 Jun 2020 15:03:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LFg5uFeW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 54CFD206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8207B6B000C; Wed, 24 Jun 2020 11:03:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7CFE66B002A; Wed, 24 Jun 2020 11:03:35 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E5E56B002B; Wed, 24 Jun 2020 11:03:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 51EBA6B000C for ; Wed, 24 Jun 2020 11:03:35 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 12648824559C for ; Wed, 24 Jun 2020 15:03:35 +0000 (UTC) X-FDA: 76964424390.22.seat79_01170f126e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 8D3291803AA92 for ; Wed, 24 Jun 2020 15:02:06 +0000 (UTC) X-Spam-Summary: 1,0,0,bc1bcc526d14afad,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:2:41:69:355:379:541:800:960:966:973:988:989:1260:1345:1359:1437:1535:1606:1730:1747:1777:1792:2196:2199:2393:2559:2562:2899:2901:3138:3139:3140:3141:3142:3355:3867:3868:3871:3872:4119:4250:4321:4385:5007:6119:6261:6653:7576:7903:8957:9413:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12683:12740:12895:14110:14394:21060:21080:21324:21444:21451:21627:21666:21990:22119:30054,0,RBL:209.85.216.66:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04y8udxgb8n5ap5bosfizk3k4t83iyczs6ucjrtnq3g8or79pi9fsu14fqbcdxp.oqzckegrtt349nggce5f98cioep88bi4jnycnd6mtciqxak6hg3wgggkfaaoyio.e-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:1:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: seat79_01170f126e45 X-Filterd-Recvd-Size: 8549 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:02:05 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id b92so1262619pjc.4 for ; Wed, 24 Jun 2020 08:02:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AX72C3H9DY0Mb5nGoxeAb59dD5E4L2tnEFRCjP+Wlf0=; b=LFg5uFeW+cQFpKjqfrepLPJFXJYZI5jo+KJSD84e95ZgJsJe6vZV1nTxVBtW+wmsb/ GoCNmNqBUvAZF3rwX5w2UQlJ2qe127xTSeU5ExIGpur6PQ2bbOgyjG+3Y0w+rB+XiX4M XGro7t420rVC4lzMJiy9rHwkRgFxGm2CkPxxQzyENzrMCgMaTS8Ca3Ybs6vJORMc1gQ4 jt4AEMla4ryL4dhP3JzwSo/Yn3MIi6s+JKWSqNsXFIKyJHOCRrnTPgVR/JS5YOh1ATZY +4GFNztX8mRXICs+o2eK4Zq5FRSexNGMtVyMMJ4t9dyCJSX7klwef3SSkaxQnGcY5QdX n3qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AX72C3H9DY0Mb5nGoxeAb59dD5E4L2tnEFRCjP+Wlf0=; b=Eio7N2wX31yvARWXOJQSGuFAhKwAOOdbQ8MRskvFokC6TkPtqMi6RE8P0YzBqBNyQx sOKNf7mC45ajlynd/eC/IwtY9t2ufigwRPpdc9a4DC741/TpljJRxynsMaDvOvlz2Lfc TT9qAUjcVsCHkFaNkJ6ce5mc8psGLcjx+JhEHS2T9e4+PGDy6IfhCKnqUIECHsLUjJHD LYR32/eIxjMsJV9qXaBu09hl7PYV/f9DRpGcnSmmU0+MF5zCeiK8EAAJpAqcGnl8r+6a En8vcGvw3DcFu+zY5qzuHEY2uLPgdSXsxUkW/7ruPI1zrS9u/oDOvKbvFOeZFVUC43rB bVuA== X-Gm-Message-State: AOAM533DhB31hIwvF6mbHMhg0fJpXe6qKfewcnfdteqW+C+XB788JPBH YysXi4c4gGj9Dde8GEghnY1yffKBYA== X-Google-Smtp-Source: ABdhPJw2R7lrU6KvkDbo3s5Q4UtioLSg9tloKIF7v1/0wtKvUe0RuwOds+r/GIlyqFv2Fuj2rCcqvw== X-Received: by 2002:a17:90a:364e:: with SMTP id s72mr6620071pjb.226.1593010924030; Wed, 24 Jun 2020 08:02:04 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:02:03 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 07/15] mm,hwpoison: Kill put_hwpoison_page Date: Wed, 24 Jun 2020 15:01:29 +0000 Message-Id: <20200624150137.7052-8-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 8D3291803AA92 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: From: Oscar Salvador After commit 4e41a30c6d50 ("mm: hwpoison: adjust for new thp refcounting"), put_hwpoison_page got reduced to a put_page. Let us just use put_page instead. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- include/linux/mm.h | 1 - mm/memory-failure.c | 30 +++++++++++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/include/linux/mm.h v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/mm.h index 050e9cffc2ea..c64ffec363b5 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/include/linux/mm.h +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/mm.h @@ -2995,7 +2995,6 @@ extern int memory_failure(unsigned long pfn, int flags); extern void memory_failure_queue(unsigned long pfn, int flags); extern void memory_failure_queue_kick(int cpu); extern int unpoison_memory(unsigned long pfn); -#define put_hwpoison_page(page) put_page(page) extern int sysctl_memory_failure_early_kill; extern int sysctl_memory_failure_recovery; extern void shake_page(struct page *p, int access); diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index 48feb45047f7..0b7d9769cf29 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -1144,7 +1144,7 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) pr_err("Memory failure: %#lx: just unpoisoned\n", pfn); num_poisoned_pages_dec(); unlock_page(head); - put_hwpoison_page(head); + put_page(head); return 0; } @@ -1336,7 +1336,7 @@ int memory_failure(unsigned long pfn, int flags) pfn); if (TestClearPageHWPoison(p)) num_poisoned_pages_dec(); - put_hwpoison_page(p); + put_page(p); return -EBUSY; } unlock_page(p); @@ -1389,14 +1389,14 @@ int memory_failure(unsigned long pfn, int flags) pr_err("Memory failure: %#lx: just unpoisoned\n", pfn); num_poisoned_pages_dec(); unlock_page(p); - put_hwpoison_page(p); + put_page(p); return 0; } if (hwpoison_filter(p)) { if (TestClearPageHWPoison(p)) num_poisoned_pages_dec(); unlock_page(p); - put_hwpoison_page(p); + put_page(p); return 0; } @@ -1630,9 +1630,9 @@ int unpoison_memory(unsigned long pfn) } unlock_page(page); - put_hwpoison_page(page); + put_page(page); if (freeit && !(pfn == my_zero_pfn(0) && page_count(p) == 1)) - put_hwpoison_page(page); + put_page(page); return 0; } @@ -1690,7 +1690,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) /* * Try to free it. */ - put_hwpoison_page(page); + put_page(page); shake_page(page, 1); /* @@ -1699,7 +1699,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) ret = __get_any_page(page, pfn, 0); if (ret == 1 && !PageLRU(page)) { /* Drop page reference which is from __get_any_page() */ - put_hwpoison_page(page); + put_page(page); pr_info("soft_offline: %#lx: unknown non LRU page type %lx (%pGp)\n", pfn, page->flags, &page->flags); return -EIO; @@ -1722,7 +1722,7 @@ static int soft_offline_huge_page(struct page *page, int flags) lock_page(hpage); if (PageHWPoison(hpage)) { unlock_page(hpage); - put_hwpoison_page(hpage); + put_page(hpage); pr_info("soft offline: %#lx hugepage already poisoned\n", pfn); return -EBUSY; } @@ -1733,7 +1733,7 @@ static int soft_offline_huge_page(struct page *page, int flags) * get_any_page() and isolate_huge_page() takes a refcount each, * so need to drop one here. */ - put_hwpoison_page(hpage); + put_page(hpage); if (!ret) { pr_info("soft offline: %#lx hugepage failed to isolate\n", pfn); return -EBUSY; @@ -1782,7 +1782,7 @@ static int __soft_offline_page(struct page *page, int flags) wait_on_page_writeback(page); if (PageHWPoison(page)) { unlock_page(page); - put_hwpoison_page(page); + put_page(page); pr_info("soft offline: %#lx page already poisoned\n", pfn); return -EBUSY; } @@ -1797,7 +1797,7 @@ static int __soft_offline_page(struct page *page, int flags) * would need to fix isolation locking first. */ if (ret == 1) { - put_hwpoison_page(page); + put_page(page); pr_info("soft_offline: %#lx: invalidated\n", pfn); SetPageHWPoison(page); num_poisoned_pages_inc(); @@ -1817,7 +1817,7 @@ static int __soft_offline_page(struct page *page, int flags) * Drop page reference which is came from get_any_page() * successful isolate_lru_page() already took another one. */ - put_hwpoison_page(page); + put_page(page); if (!ret) { LIST_HEAD(pagelist); /* @@ -1861,7 +1861,7 @@ static int soft_offline_in_use_page(struct page *page, int flags) pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page)); else pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page)); - put_hwpoison_page(page); + put_page(page); return -EBUSY; } unlock_page(page); @@ -1934,7 +1934,7 @@ int soft_offline_page(unsigned long pfn, int flags) if (PageHWPoison(page)) { pr_info("soft offline: %#lx page already poisoned\n", pfn); if (flags & MF_COUNT_INCREASED) - put_hwpoison_page(page); + put_page(page); return -EBUSY; } From patchwork Wed Jun 24 15:01:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623383 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9DFF7912 for ; Wed, 24 Jun 2020 15:03:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6A9342082F for ; Wed, 24 Jun 2020 15:03:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QeREAFiE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A9342082F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6245B6B0023; Wed, 24 Jun 2020 11:03:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5D41D6B0024; Wed, 24 Jun 2020 11:03:11 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C2C16B0025; Wed, 24 Jun 2020 11:03:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id 34CEC6B0023 for ; Wed, 24 Jun 2020 11:03:11 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E72C718012CDA for ; Wed, 24 Jun 2020 15:03:10 +0000 (UTC) X-FDA: 76964423340.10.dolls70_1b0185326e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 407649994 for ; Wed, 24 Jun 2020 15:02:16 +0000 (UTC) X-Spam-Summary: 1,0,0,fa934708419eaffa,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:966:968:973:988:989:1260:1345:1359:1437:1535:1543:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2553:2559:2562:2899:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:4117:4321:4385:5007:6261:6653:7576:9010:9413:9592:10004:11026:11232:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12740:12895:13972:14093:14181:14394:14721:21060:21080:21444:21627:21666:21795:21939:21990:22119:30051:30054:30070:30090,0,RBL:209.85.210.196:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yr46yesoqam1g7t9pn4fwuz1qi8yc14o4wzgmwdg3r46u9cux3qzqkbashqgo.kuhty7ytnjjg9cjrzp1c3w6g3o9fay3cp7eoda4jdju9iwbsuzhrdbmnp3rw448.o-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: dolls70_1b0185326e45 X-Filterd-Recvd-Size: 6109 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:02:08 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id j1so1281674pfe.4 for ; Wed, 24 Jun 2020 08:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WIp32P5EtOq+fwbI5DTsLYoiz2wHcW1kKrBDwwP58qc=; b=QeREAFiEgaNBS4YRTqqFz2rem0RoU+ypFV3pOa3g9stlE+R4D1whcZhBtTL+hNIylf WYRaVIXj0M47cSmcdflAEHp7L8cHP9X8MXErtgXs8J3oJ/V9u1Er5qau1FMStlctTE3q wAH1VadiOn20gm2EJs2NOGJS0jsv+0zUzh5ntz/sGG+njNrEiPCn1RSw3KRDJ7HHe+wG 9CJiMNUxUG6eBh1jf3EsZ2hRVpcOjKMI671AQ2YL3PflTWugVTgoLQ9R1NyfDx5CnLtN ntvYw/FFqfVGFzQ4bKqQVv+3B6Z/XDAHDk9lF/XyiUF02CIgjL7YcBrotCGSVgul+GAP MuMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WIp32P5EtOq+fwbI5DTsLYoiz2wHcW1kKrBDwwP58qc=; b=rZU0p941YyTLuRXSDZGlTtMaPMGqq0/W7fBWUgaoPe3tEmh2IWBkbcRXB2JadCkQCT sY3aLrOZcXehEhfvmoYPu3ePgA3b9zrDH7AgBnXfrbbwkOH4dldX91QdhHRIf6d9VmSH gXrt8xp+BTiCkRDfrJmpxIp2ODUzNgJKSt7OcciMzzfs7IRo1K2GmoYL/OKDhpdpUPNn pMJdt4ugxWeOyncUFVr1NTco/+v9TBmwAA5rAqAqogr/rjbJlvJTChr5WIjqzRqeFjEq KLrwNO5kwWvBDNRPqOhD8IJRmMHK2nY/kEEAAWHX/5kIUZ+viv+Hw+z5ZTNwSQjwbo1A wljw== X-Gm-Message-State: AOAM531NnnZX7svP94+DosxtgFXAdQwUz4Ct6EkMjpE8S/D9gV/mHdDR +FWRWv6W1fni/QfvfxTSYnjUOT2TKg== X-Google-Smtp-Source: ABdhPJxcv5SZFzXZ84c+ThvF5kyNv7fJOWZ9YSNA90GU6F5kZmjIk37nmIyvzofkgL5cHZeJ6WHdOg== X-Received: by 2002:a62:de84:: with SMTP id h126mr28948688pfg.37.1593010927232; Wed, 24 Jun 2020 08:02:07 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.02.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:02:06 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 08/15] mm,hwpoison: remove MF_COUNT_INCREASED Date: Wed, 24 Jun 2020 15:01:30 +0000 Message-Id: <20200624150137.7052-9-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 407649994 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: From: Naoya Horiguchi Now there's no user of MF_COUNT_INCREASED, so we can safely remove it from all calling points. Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador --- include/linux/mm.h | 7 +++---- mm/memory-failure.c | 14 +++----------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/include/linux/mm.h v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/mm.h index c64ffec363b5..229efb3479b1 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/include/linux/mm.h +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/mm.h @@ -2986,10 +2986,9 @@ void register_page_bootmem_memmap(unsigned long section_nr, struct page *map, unsigned long nr_pages); enum mf_flags { - MF_COUNT_INCREASED = 1 << 0, - MF_ACTION_REQUIRED = 1 << 1, - MF_MUST_KILL = 1 << 2, - MF_SOFT_OFFLINE = 1 << 3, + MF_ACTION_REQUIRED = 1 << 0, + MF_MUST_KILL = 1 << 1, + MF_SOFT_OFFLINE = 1 << 2, }; extern int memory_failure(unsigned long pfn, int flags); extern void memory_failure_queue(unsigned long pfn, int flags); diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index 0b7d9769cf29..15b8e7fd94ed 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -1118,7 +1118,7 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) num_poisoned_pages_inc(); - if (!(flags & MF_COUNT_INCREASED) && !get_hwpoison_page(p)) { + if (!get_hwpoison_page(p)) { /* * Check "filter hit" and "race with other subpage." */ @@ -1314,7 +1314,7 @@ int memory_failure(unsigned long pfn, int flags) * In fact it's dangerous to directly bump up page count from 0, * that may make page_ref_freeze()/page_ref_unfreeze() mismatch. */ - if (!(flags & MF_COUNT_INCREASED) && !get_hwpoison_page(p)) { + if (!get_hwpoison_page(p)) { if (is_free_buddy_page(p)) { action_result(pfn, MF_MSG_BUDDY, MF_DELAYED); return 0; @@ -1354,10 +1354,7 @@ int memory_failure(unsigned long pfn, int flags) shake_page(p, 0); /* shake_page could have turned it free. */ if (!PageLRU(p) && is_free_buddy_page(p)) { - if (flags & MF_COUNT_INCREASED) - action_result(pfn, MF_MSG_BUDDY, MF_DELAYED); - else - action_result(pfn, MF_MSG_BUDDY_2ND, MF_DELAYED); + action_result(pfn, MF_MSG_BUDDY_2ND, MF_DELAYED); return 0; } @@ -1655,9 +1652,6 @@ static int __get_any_page(struct page *p, unsigned long pfn, int flags) { int ret; - if (flags & MF_COUNT_INCREASED) - return 1; - /* * When the target page is a free hugepage, just remove it * from free hugepage list. @@ -1933,8 +1927,6 @@ int soft_offline_page(unsigned long pfn, int flags) if (PageHWPoison(page)) { pr_info("soft offline: %#lx page already poisoned\n", pfn); - if (flags & MF_COUNT_INCREASED) - put_page(page); return -EBUSY; } From patchwork Wed Jun 24 15:01:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623399 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CC9360D for ; Wed, 24 Jun 2020 15:03:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3CF2E206C0 for ; Wed, 24 Jun 2020 15:03:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G7MoKVKx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CF2E206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 00AF76B000D; Wed, 24 Jun 2020 11:03:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EFC396B002A; Wed, 24 Jun 2020 11:03:45 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E12CF6B002B; Wed, 24 Jun 2020 11:03:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0062.hostedemail.com [216.40.44.62]) by kanga.kvack.org (Postfix) with ESMTP id C66D16B000D for ; Wed, 24 Jun 2020 11:03:45 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7DD298245571 for ; Wed, 24 Jun 2020 15:03:45 +0000 (UTC) X-FDA: 76964424810.26.legs75_56064aa26e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 168D318016E99 for ; Wed, 24 Jun 2020 15:02:15 +0000 (UTC) X-Spam-Summary: 1,0,0,f28bab7f7b86421b,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:2:41:69:355:379:541:800:960:966:968:973:988:989:1260:1345:1359:1437:1535:1605:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2899:2901:3138:3139:3140:3141:3142:3865:3866:3867:3868:3871:3872:3874:4049:4120:4321:4385:4470:4605:5007:6119:6261:6653:7576:7875:7903:8957:9036:9413:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12740:12895:12986:13146:13161:13229:13230:14394:21060:21080:21444:21611:21627:21666:21740:21990:22119:30003:30054,0,RBL:209.85.215.193:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yfopd8n94frf5tn9embgazxou4oycotdoxo77zoawiwsox1iku4153aiohuof.f1rf74qcbkjgn5mxs736koya11zrhnsdc16o5bjpeqgc8sbmz6gau5fz6ojycha.e-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:1:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: legs75_56064aa26e45 X-Filterd-Recvd-Size: 9367 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:02:11 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id e9so1537679pgo.9 for ; Wed, 24 Jun 2020 08:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jEC53F5SPXIDcc5jWStknbQ9117ExLc2PS78CholLvg=; b=G7MoKVKx1VUGb9vnXguZhgBeFJkuKF9NEW8T8jp0k/P1z3BFRRySMLN0qoKTHSBe60 A2AnZ0JeffOGNpnbnDtlTVMezWm50xKTcBXrIbK4jiiLXXsqkCK9Dica8fq+dc8e9VQ3 wKsmIOoBbb73v6dLhUP+Y85Gj9AK/vXIReG/iPPBCaFu2vTHHtq4F+9YIZbkoU8HOCd3 D5k2dMQw0lVRJvH6tfznXyD7/yc2cLpB1AX2fN87E7AjzSaPJbIuod6bz5S/pvC7TKMV EDAN48Cv3KLAMFhvQG16KcjQSS5SdHErK7gvNnFFP/Vfhyrvn7ogxDyyZGyD+UE3Ic4B ePvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jEC53F5SPXIDcc5jWStknbQ9117ExLc2PS78CholLvg=; b=RJb1AfRKIAivwnTG//bxkyrVUV8pVUYTmNpBPgyzufTYC+PHcLZUgk8ggIQDhtbDtD Dz4YidASSfGz8RHb4wfr7WoYD7V9G8v4cX85kPV+dpN3fAxWbtmbPZgfJcewRgrC+hQN jBMr/6Wg9A9VgT/+DXc6ByoIEyzc7oCKn5JoBPqOOKP4T6lQbfHhNwn7JlUt6bu/+F2N 3cnTioXmr58aHOYQ2lpY+sarrLMjEzuLZ8fp78tgnPPrAxsertASJirA6PFyC0Wy1guE 9FpgM5gCg3BhdyIma5gMV+F3y6rlM2+5FOueP/l+HB/ACHE60Giq0hdzd7520F6IWi4A LZDQ== X-Gm-Message-State: AOAM530TuBcTGlvwthGW2wI5wkhHXbHStb/R1tDXqcHWW/8D2FkcizLk 3yDaUOmtUtoocdQ1XZ1j+puT0CAt5g== X-Google-Smtp-Source: ABdhPJxm+JnjvpU80AoxHh+Had8XftzaYnZAP7GzsXlzh51MZfQygKr75m3W9vBMzEYpKNHFs9KV4Q== X-Received: by 2002:a62:834c:: with SMTP id h73mr31147208pfe.221.1593010930240; Wed, 24 Jun 2020 08:02:10 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.02.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:02:09 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 09/15] mm,hwpoison: remove flag argument from soft offline functions Date: Wed, 24 Jun 2020 15:01:31 +0000 Message-Id: <20200624150137.7052-10-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 168D318016E99 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: From: Naoya Horiguchi The argument @flag no longer affects the behavior of soft_offline_page() and its variants, so let's remove them. Signed-off-by: Naoya Horiguchi Signed-off-by: Oscar Salvador --- drivers/base/memory.c | 2 +- include/linux/mm.h | 2 +- mm/madvise.c | 2 +- mm/memory-failure.c | 27 +++++++++++++-------------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/drivers/base/memory.c v5.8-rc1-mmots-2020-06-20-21-44_patched/drivers/base/memory.c index 2b09b68b9f78..20664f279c99 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/drivers/base/memory.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/drivers/base/memory.c @@ -463,7 +463,7 @@ static ssize_t soft_offline_page_store(struct device *dev, if (kstrtoull(buf, 0, &pfn) < 0) return -EINVAL; pfn >>= PAGE_SHIFT; - ret = soft_offline_page(pfn, 0); + ret = soft_offline_page(pfn); return ret == 0 ? count : ret; } diff --git v5.8-rc1-mmots-2020-06-20-21-44/include/linux/mm.h v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/mm.h index 229efb3479b1..d708033c50c0 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/include/linux/mm.h +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/mm.h @@ -2998,7 +2998,7 @@ extern int sysctl_memory_failure_early_kill; extern int sysctl_memory_failure_recovery; extern void shake_page(struct page *p, int access); extern atomic_long_t num_poisoned_pages __read_mostly; -extern int soft_offline_page(unsigned long pfn, int flags); +extern int soft_offline_page(unsigned long pfn); /* diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/madvise.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c index bee1f4ac70d6..2b5080253406 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/madvise.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c @@ -908,7 +908,7 @@ static int madvise_inject_error(int behavior, if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", pfn, start); - ret = soft_offline_page(pfn, 0); + ret = soft_offline_page(pfn); } else { pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", pfn, start); diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index 15b8e7fd94ed..03d3aae77f89 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -1502,7 +1502,7 @@ static void memory_failure_work_func(struct work_struct *work) if (!gotten) break; if (entry.flags & MF_SOFT_OFFLINE) - soft_offline_page(entry.pfn, entry.flags); + soft_offline_page(entry.pfn); else memory_failure(entry.pfn, entry.flags); } @@ -1648,7 +1648,7 @@ static struct page *new_page(struct page *p, unsigned long private) * that is not free, and 1 for any other page type. * For 1 the page is returned with increased page count, otherwise not. */ -static int __get_any_page(struct page *p, unsigned long pfn, int flags) +static int __get_any_page(struct page *p, unsigned long pfn) { int ret; @@ -1675,9 +1675,9 @@ static int __get_any_page(struct page *p, unsigned long pfn, int flags) return ret; } -static int get_any_page(struct page *page, unsigned long pfn, int flags) +static int get_any_page(struct page *page, unsigned long pfn) { - int ret = __get_any_page(page, pfn, flags); + int ret = __get_any_page(page, pfn); if (ret == 1 && !PageHuge(page) && !PageLRU(page) && !__PageMovable(page)) { @@ -1690,7 +1690,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) /* * Did it turn free? */ - ret = __get_any_page(page, pfn, 0); + ret = __get_any_page(page, pfn); if (ret == 1 && !PageLRU(page)) { /* Drop page reference which is from __get_any_page() */ put_page(page); @@ -1702,7 +1702,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) return ret; } -static int soft_offline_huge_page(struct page *page, int flags) +static int soft_offline_huge_page(struct page *page) { int ret; unsigned long pfn = page_to_pfn(page); @@ -1761,7 +1761,7 @@ static int soft_offline_huge_page(struct page *page, int flags) return ret; } -static int __soft_offline_page(struct page *page, int flags) +static int __soft_offline_page(struct page *page) { int ret; unsigned long pfn = page_to_pfn(page); @@ -1841,7 +1841,7 @@ static int __soft_offline_page(struct page *page, int flags) return ret; } -static int soft_offline_in_use_page(struct page *page, int flags) +static int soft_offline_in_use_page(struct page *page) { int ret; int mt; @@ -1871,9 +1871,9 @@ static int soft_offline_in_use_page(struct page *page, int flags) mt = get_pageblock_migratetype(page); set_pageblock_migratetype(page, MIGRATE_ISOLATE); if (PageHuge(page)) - ret = soft_offline_huge_page(page, flags); + ret = soft_offline_huge_page(page); else - ret = __soft_offline_page(page, flags); + ret = __soft_offline_page(page); set_pageblock_migratetype(page, mt); return ret; } @@ -1894,7 +1894,6 @@ static int soft_offline_free_page(struct page *page) /** * soft_offline_page - Soft offline a page. * @pfn: pfn to soft-offline - * @flags: flags. Same as memory_failure(). * * Returns 0 on success, otherwise negated errno. * @@ -1913,7 +1912,7 @@ static int soft_offline_free_page(struct page *page) * This is not a 100% solution for all memory, but tries to be * ``good enough'' for the majority of memory. */ -int soft_offline_page(unsigned long pfn, int flags) +int soft_offline_page(unsigned long pfn) { int ret; struct page *page; @@ -1931,11 +1930,11 @@ int soft_offline_page(unsigned long pfn, int flags) } get_online_mems(); - ret = get_any_page(page, pfn, flags); + ret = get_any_page(page, pfn); put_online_mems(); if (ret > 0) - ret = soft_offline_in_use_page(page, flags); + ret = soft_offline_in_use_page(page); else if (ret == 0) ret = soft_offline_free_page(page); From patchwork Wed Jun 24 15:01:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623407 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14C5E912 for ; Wed, 24 Jun 2020 15:04:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CC555206C0 for ; Wed, 24 Jun 2020 15:04:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W+u5EdOV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC555206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C18846B0031; Wed, 24 Jun 2020 11:04:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BEE7E6B0033; Wed, 24 Jun 2020 11:04:39 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B041A6B0036; Wed, 24 Jun 2020 11:04:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0042.hostedemail.com [216.40.44.42]) by kanga.kvack.org (Postfix) with ESMTP id 96ECB6B0031 for ; Wed, 24 Jun 2020 11:04:39 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 569E052B0 for ; Wed, 24 Jun 2020 15:04:39 +0000 (UTC) X-FDA: 76964427078.25.sleet31_2b17cd926e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id EE8EE18024AE7 for ; Wed, 24 Jun 2020 15:02:15 +0000 (UTC) X-Spam-Summary: 1,0,0,e5e90fb9923f1898,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:69:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:2693:2899:3138:3139:3140:3141:3142:3353:3865:3866:3868:3870:3872:3874:4321:5007:6119:6120:6261:6653:7576:7901:7903:8957:9413:10004:11026:11473:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12679:12683:12740:12895:14110:14181:14394:14721:21060:21080:21444:21627:21666:21990:22119:30012:30054,0,RBL:209.85.210.195:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04y89ugnop3zt5hgxtw84dx5imgiiycwjrruke9i1pnp3ghmwbmgg6ng74acuhz.sirwfnw53onwodczxjyznpf8q9qs4nwzibzd673c3cdp3zx643ss5zkr8uwo8gg.g-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: sleet31_2b17cd926e45 X-Filterd-Recvd-Size: 5805 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:02:14 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id b5so1270200pfp.9 for ; Wed, 24 Jun 2020 08:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=joeQ3SaeYT7GDsb9cUatgWWRJkFAFZeG8Ak2AOs52Qk=; b=W+u5EdOVfTsbqirIRrlaAE605oWdqSInb8/ROWc9uVHpy8/ZacyCg8Cvx1/hmSHNe1 3t51LQ0cHlHri3xOg02J38+lDjmHh3wBw+foyeO/wqb7929YCVjbddys+s8+dI/LS4PF Sxzxf7Hvc2UfpdsS/ehNrjqX3Ph4Hd7h7xsGsSHcfMvWKYD4GpjEA7zaZ9nlGM5Akg3O 6AoX+kE0TccktjuQ7LhdFewIo+XHlINyZtQLSBwnBBCsiqP2M/uf5J+HSW4MHyciDwnx wYGY1PXBe/Snv92WcoAbx1wMStUJ9ssnqFHSnEd6DMBPvYVhD1BoaWW6rUThQAGdqPXA 0bvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=joeQ3SaeYT7GDsb9cUatgWWRJkFAFZeG8Ak2AOs52Qk=; b=M6SFZvHP+VPb/drHF6Dgk+nz8XOtr7vDxUXB6KUP6CkYtmHmjMFCAAAROaNTYK7xg3 yaqyfjl91NBytH6LMt/BCH3+eyRnUox42eu/TB7OAOOsiucImkw6dVs/1rIQ45m+vJ5B 84aZjpdkm94FjK9eUsorkGI7L15Ycq08WFHwX4uODW3UBWPcNdXiodcijV/pTemI0Y1Q o93/dBE6umLSbe/ilVusz1ApIo0afZ0Du79/Zk/BMNdEbCqfG+8EYaHc4kBAq/v4fBOa EWGoG9HG3lLo0m31E2aYSnUzbeL3UFXwNQ7omBnNEucMWCn6J/j74IJS9NSyxrLRVR4I mldA== X-Gm-Message-State: AOAM533qrFsMggbc5pYixJCM5JQUfhoSEmExz0ywAkcHr/6qSQ+DTqvR UDQ/N8lEaxo2XEBR62hjpwSgAYd/IQ== X-Google-Smtp-Source: ABdhPJztXHW2r62m+tAG4OOCPW60g7TBHFl5rgmkuHiE/2l+QSOogErW+UJQ+iv40PhXFbMvLae0OA== X-Received: by 2002:a62:1716:: with SMTP id 22mr2825390pfx.99.1593010933234; Wed, 24 Jun 2020 08:02:13 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:02:12 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 10/15] mm,hwpoison: Unify THP handling for hard and soft offline Date: Wed, 24 Jun 2020 15:01:32 +0000 Message-Id: <20200624150137.7052-11-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: EE8EE18024AE7 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Oscar Salvador Place the THP's page handling in a helper and use it from both hard and soft-offline machinery, so we get rid of some duplicated code. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 48 +++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 26 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index 03d3aae77f89..2e244d5b83e0 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -1103,6 +1103,25 @@ static int identify_page_state(unsigned long pfn, struct page *p, return page_action(ps, p, pfn); } +static int try_to_split_thp_page(struct page *page, const char *msg) +{ + lock_page(page); + if (!PageAnon(page) || unlikely(split_huge_page(page))) { + unsigned long pfn = page_to_pfn(page); + + unlock_page(page); + if (!PageAnon(page)) + pr_info("%s: %#lx: non anonymous thp\n", msg, pfn); + else + pr_info("%s: %#lx: thp split failed\n", msg, pfn); + put_page(page); + return -EBUSY; + } + unlock_page(page); + + return 0; +} + static int memory_failure_hugetlb(unsigned long pfn, int flags) { struct page *p = pfn_to_page(pfn); @@ -1325,21 +1344,8 @@ int memory_failure(unsigned long pfn, int flags) } if (PageTransHuge(hpage)) { - lock_page(p); - if (!PageAnon(p) || unlikely(split_huge_page(p))) { - unlock_page(p); - if (!PageAnon(p)) - pr_err("Memory failure: %#lx: non anonymous thp\n", - pfn); - else - pr_err("Memory failure: %#lx: thp split failed\n", - pfn); - if (TestClearPageHWPoison(p)) - num_poisoned_pages_dec(); - put_page(p); + if (try_to_split_thp_page(p, "Memory Failure") < 0) return -EBUSY; - } - unlock_page(p); VM_BUG_ON_PAGE(!page_count(p), p); } @@ -1847,19 +1853,9 @@ static int soft_offline_in_use_page(struct page *page) int mt; struct page *hpage = compound_head(page); - if (!PageHuge(page) && PageTransHuge(hpage)) { - lock_page(page); - if (!PageAnon(page) || unlikely(split_huge_page(page))) { - unlock_page(page); - if (!PageAnon(page)) - pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page)); - else - pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page)); - put_page(page); + if (!PageHuge(page) && PageTransHuge(hpage)) + if (try_to_split_thp_page(page, "soft offline") < 0) return -EBUSY; - } - unlock_page(page); - } /* * Setting MIGRATE_ISOLATE here ensures that the page will be linked From patchwork Wed Jun 24 15:01:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623377 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DDB160D for ; Wed, 24 Jun 2020 15:02:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CF73C206C0 for ; Wed, 24 Jun 2020 15:02:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RirjVn7v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF73C206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 895876B0022; Wed, 24 Jun 2020 11:02:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 86E626B0023; Wed, 24 Jun 2020 11:02:57 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75B816B0024; Wed, 24 Jun 2020 11:02:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id 5F4A96B0022 for ; Wed, 24 Jun 2020 11:02:57 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0D9DC181ABE89 for ; Wed, 24 Jun 2020 15:02:57 +0000 (UTC) X-FDA: 76964422794.17.crush90_3f00fb226e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id BE9A718037D44 for ; Wed, 24 Jun 2020 15:02:17 +0000 (UTC) X-Spam-Summary: 1,0,0,8dc050e0426d5410,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:2:41:355:379:541:800:960:965:966:973:988:989:1260:1345:1359:1437:1535:1606:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2693:2731:2898:2899:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:4119:4321:4385:4390:4395:4421:4605:5007:6119:6261:6653:7576:7875:7903:8603:8660:8957:9036:9413:9707:10004:11026:11232:11473:11658:11914:12043:12291:12296:12297:12438:12517:12519:12555:12679:12683:12740:12895:12986:13148:13161:13229:13230:14096:14394:21060:21080:21094:21323:21444:21451:21627:21666:21939:21990:22119:30054:30070,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yrmaupo5uz3tt5knupnqcbexxn8ypxhyq5tqirjjicg1nyjxx364ioou6d1qt.am45sdedceudt3dr51uqxtmg6fm56wwfhw1wgz6jot4ohwqqzdjo745ckxerfbi.y-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:ne utral,Cu X-HE-Tag: crush90_3f00fb226e45 X-Filterd-Recvd-Size: 8311 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:02:17 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id s10so1559882pgm.0 for ; Wed, 24 Jun 2020 08:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wemqwQ1fREh2JQiEeDLgUYZf8kZ33feb3ynoN9bhMsM=; b=RirjVn7v29G812b9rUw+VgI8Ua6kOb8Jr6ZOXICjDbQZeonzIS2UoWkCEQAI5yDd+F NyopQadvFl9mqn+qPcaFHJcUACIyDlmJb+MQBRNihqMlvpztvaZXMI1vUpyC7Y5DO8OS 1rTpDL34JTHvbBlGDgGaN9dvj+6y0oD3LXSCRW5HDn2jOT5L67PitxwDKfoctqNJsnSF Wt7q+fPbNGciparr7btfdoaQI59tMQFA1zHLSoPRZZB4IRJTpuKcEgKMiCwBNLl6sldU LTSM1+Fj/phtoyX8laylAC7CAp6qW503gHNfvt8O0o2DUwK+D0Fyz6CLVwIwk2Vv8puW jGbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wemqwQ1fREh2JQiEeDLgUYZf8kZ33feb3ynoN9bhMsM=; b=TxCDorq4AOJX3CG1+r9UnsLhhnz57HL2tdXrhHDofOf/IP2CKIo6xGAuQCSF1NgDLG aUOgFC6Haqesl4LsNNXmi6NOgiicccInQ/C8BZ1Ok3+IUyy1xU7o2x0kMDZTZfzOk8GV IP7mleip8HBLL+ThA8tWqeC6aK2s5tl0j3AHyeGi1LxBDxsC16segk53gwvnwhYORIIz 2CK+yJxe1uHzDfo8Lu9apbOn1jWLJMvbl8TH4qaZiQ81x8GumojiSi/LdV1QKetEFhzY JkflkJEthFxn2Q8H7R2q+99Zlc78jQPQbKHk31VtZgRlqfNqmOWbnE3J2xmvEDIzZ/BA Fy/A== X-Gm-Message-State: AOAM530w3bRCQiDA+O1n1Ym2qhJabnZGAsbZgXpYtFOHXM9JdgY4TJ8A a9LiJIZEWKGX0frQLS+G8C9RbrlzvQ== X-Google-Smtp-Source: ABdhPJySf0N9YCkY0AXDYfVlBg+AcGHmUzuKDEj3LCHQGl686X2BH03jtPIyL7vSty+G9GsBNxEYyA== X-Received: by 2002:aa7:972d:: with SMTP id k13mr30001279pfg.113.1593010936217; Wed, 24 Jun 2020 08:02:16 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:02:15 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 11/15] mm,hwpoison: Rework soft offline for free pages Date: Wed, 24 Jun 2020 15:01:33 +0000 Message-Id: <20200624150137.7052-12-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: BE9A718037D44 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: From: Oscar Salvador When trying to soft-offline a free page, we need to first take it off the buddy allocator. Once we know is out of reach, we can safely flag it as poisoned. take_page_off_buddy will be used to take a page meant to be poisoned off the buddy allocator. take_page_off_buddy calls break_down_buddy_pages, which splits a higher-order page in case our page belongs to one. Once the page is under our control, we call page_handle_poison to set it as poisoned and grab a refcount on it. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- ChangeLog v2 -> v3: - use add_to_free_list() instead of add_to_free_area() - use del_page_from_free_list() instead of del_page_from_free_area() - add fast return - move extern definition to header file as warned by checkpatch.pl --- include/linux/page-flags.h | 1 + mm/memory-failure.c | 18 ++++++---- mm/page_alloc.c | 68 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 6 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/include/linux/page-flags.h v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/page-flags.h index 6be1aa559b1e..9fa5d4e2d69a 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/include/linux/page-flags.h +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/page-flags.h @@ -423,6 +423,7 @@ PAGEFLAG(HWPoison, hwpoison, PF_ANY) TESTSCFLAG(HWPoison, hwpoison, PF_ANY) #define __PG_HWPOISON (1UL << PG_hwpoison) extern bool set_hwpoison_free_buddy_page(struct page *page); +extern bool take_page_off_buddy(struct page *page); #else PAGEFLAG_FALSE(HWPoison) static inline bool set_hwpoison_free_buddy_page(struct page *page) diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index 2e244d5b83e0..d79e756a97be 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -78,6 +78,13 @@ EXPORT_SYMBOL_GPL(hwpoison_filter_dev_minor); EXPORT_SYMBOL_GPL(hwpoison_filter_flags_mask); EXPORT_SYMBOL_GPL(hwpoison_filter_flags_value); +static void page_handle_poison(struct page *page) +{ + SetPageHWPoison(page); + page_ref_inc(page); + num_poisoned_pages_inc(); +} + static int hwpoison_filter_dev(struct page *p) { struct address_space *mapping; @@ -1876,14 +1883,13 @@ static int soft_offline_in_use_page(struct page *page) static int soft_offline_free_page(struct page *page) { - int rc = dissolve_free_huge_page(page); + int rc = -EBUSY; - if (!rc) { - if (set_hwpoison_free_buddy_page(page)) - num_poisoned_pages_inc(); - else - rc = -EBUSY; + if (!dissolve_free_huge_page(page) && take_page_off_buddy(page)) { + page_handle_poison(page); + rc = 0; } + return rc; } diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/page_alloc.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/page_alloc.c index 31c32fe0ecfb..3b145bceb477 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/page_alloc.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/page_alloc.c @@ -8781,6 +8781,74 @@ bool is_free_buddy_page(struct page *page) } #ifdef CONFIG_MEMORY_FAILURE +/* + * Break down a higher-order page in sub-pages, and keep our target out of + * buddy allocator. + */ +static void break_down_buddy_pages(struct zone *zone, struct page *page, + struct page *target, int low, int high, + int migratetype) +{ + unsigned long size = 1 << high; + struct page *current_buddy, *next_page; + + while (high > low) { + high--; + size >>= 1; + + if (target >= &page[size]) { + next_page = page + size; + current_buddy = page; + } else { + next_page = page; + current_buddy = page + size; + } + + if (set_page_guard(zone, current_buddy, high, migratetype)) + continue; + + if (current_buddy != target) { + add_to_free_list(current_buddy, zone, high, migratetype); + set_page_order(current_buddy, high); + page = next_page; + } + } +} + +/* + * Take a page that will be marked as poisoned off the buddy allocator. + */ +bool take_page_off_buddy(struct page *page) +{ + struct zone *zone = page_zone(page); + unsigned long pfn = page_to_pfn(page); + unsigned long flags; + unsigned int order; + bool ret = false; + + spin_lock_irqsave(&zone->lock, flags); + for (order = 0; order < MAX_ORDER; order++) { + struct page *page_head = page - (pfn & ((1 << order) - 1)); + int buddy_order = page_order(page_head); + + if (PageBuddy(page_head) && buddy_order >= order) { + unsigned long pfn_head = page_to_pfn(page_head); + int migratetype = get_pfnblock_migratetype(page_head, + pfn_head); + + del_page_from_free_list(page_head, zone, buddy_order); + break_down_buddy_pages(zone, page_head, page, 0, + buddy_order, migratetype); + ret = true; + break; + } + if (page_count(page_head) > 0) + break; + } + spin_unlock_irqrestore(&zone->lock, flags); + return ret; +} + /* * Set PG_hwpoison flag if a given page is confirmed to be a free page. This * test is performed under the zone lock to prevent a race against page From patchwork Wed Jun 24 15:01:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623393 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 10EAA912 for ; Wed, 24 Jun 2020 15:03:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C433D206C0 for ; Wed, 24 Jun 2020 15:03:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QaLRGFBO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C433D206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6E8596B0026; Wed, 24 Jun 2020 11:03:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 698F06B0027; Wed, 24 Jun 2020 11:03:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53A6C6B0028; Wed, 24 Jun 2020 11:03:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0066.hostedemail.com [216.40.44.66]) by kanga.kvack.org (Postfix) with ESMTP id 3D80D6B0026 for ; Wed, 24 Jun 2020 11:03:26 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id ED53C1A4CB for ; Wed, 24 Jun 2020 15:03:25 +0000 (UTC) X-FDA: 76964423970.19.drain80_210836426e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 9B1F9190BC for ; Wed, 24 Jun 2020 15:02:24 +0000 (UTC) X-Spam-Summary: 1,0,0,ec5a383ee318805e,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:1:2:41:69:355:379:541:800:960:966:973:988:989:1260:1345:1359:1437:1605:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2693:2731:2899:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3872:3874:4052:4250:4321:4385:4605:5007:6119:6261:6653:7576:7875:7903:8660:8957:9010:9413:9592:9707:10004:11026:11232:11473:11658:11914:12043:12257:12296:12297:12438:12517:12519:12555:12679:12683:12740:12895:13148:13230:14096:14394:21060:21080:21094:21323:21324:21444:21451:21627:21666:21740:21795:21939:21987:21990:22119:30012:30051:30054:30070:30083:30091,0,RBL:209.85.214.196:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04y894hwjm579toxgd7swaqn8oh4bopahqr1kwan5dimdngm6dckh33w3asfex3.axfopzzridaaw8rwrcykk9zoe7rbmknkotq9obuzu8cb7mbnga3dke3kuopsobw.o-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DN SBL:neut X-HE-Tag: drain80_210836426e45 X-Filterd-Recvd-Size: 12896 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:02:20 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id 35so1174109ple.0 for ; Wed, 24 Jun 2020 08:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GUNynxl8EV7sXCufCcmxBHs/J/t13PuDOABln2FP2HY=; b=QaLRGFBOpYLfo3KElRWDb/N+ZUOYT4JiTTQhQOp4UTbfOflbSHQqPwcS9I4EOVTs4G IUEaKFXTFCMnMbELCfL847hSUmfheSlrn5s9LKtNAmqVz9h1BYA+XRAufX67buBfRxkg NPI89RvIQb2BeudSjfAJB0SSznTuspk/iYVpH2HU4JZJ4Yy5cGPo+znfyPEPb9cvSz2n aiUhBmtNRwxHn59N3P6E+7UTN/4XBcFx8FWOQsRr1+Sb6/9WrGrhSZCOjDvI4repjLiG jRM+s4HSJ2GsID+YKnVCYuaB6xtTVthLNUeitf+T4/tLXNuiXeYeQqTbkDhn4zuDugU4 LDow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GUNynxl8EV7sXCufCcmxBHs/J/t13PuDOABln2FP2HY=; b=ZpOKIqkigNPqFr0M4jQ6NmQY1MLtBJoXaRkUHj0CzB9/klvuvskvI/QuxadM6kA9Wf zRnsBq2MucKTWYvk3Ei2uHnTWR2e8GLDncntUhVcPRDHI21bTYjZQdw//d99+lVqVc1j VoeAlvxGBIYmQ1W6vxhQdJa3PTmI4zChirpnWnfpAqKDIzIExaWnbHT/nTGylC+YCbF+ nShF44QU//TjEGlTZZB/4XbXRzE2/suooNeVjtate+QzC0sqq+xaGEWyv3fQTTq77HZM K99jb8r6Xbmy/xk5t+zi1eLlazq2wrFKpotDzJcWtVLef7Mt/aSM0b5p5w2FmkVsviWv SrHQ== X-Gm-Message-State: AOAM531IIqfrvokrH69r64zvSLnUuPmG0qyYvlysEAj1YlRkDXltC5Hi yxzENiKZ2GfY/ZlRw6fmssvSxrdAhg== X-Google-Smtp-Source: ABdhPJyTloXvGWvJr8+6caJEix7U+ixydVE9Wei2bf+99EFnkVXi+PNL0DCIucJrHmvE5Lq6WT3Kxw== X-Received: by 2002:a17:90a:fcc:: with SMTP id 70mr27771463pjz.106.1593010939488; Wed, 24 Jun 2020 08:02:19 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:02:18 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 12/15] mm,hwpoison: Rework soft offline for in-use pages Date: Wed, 24 Jun 2020 15:01:34 +0000 Message-Id: <20200624150137.7052-13-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 9B1F9190BC X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: From: Oscar Salvador This patch changes the way we set and handle in-use poisoned pages. Until now, poisoned pages were released to the buddy allocator, trusting that the checks that take place prior to hand the page would act as a safe net and would skip that page. This has proved to be wrong, as we got some pfn walkers out there, like compaction, that all they care is the page to be PageBuddy and be in a freelist. Although this might not be the only user, having poisoned pages in the buddy allocator seems a bad idea as we should only have free pages that are ready and meant to be used as such. Before explaining the taken approach, let us break down the kind of pages we can soft offline. - Anonymous THP (after the split, they end up being 4K pages) - Hugetlb - Order-0 pages (that can be either migrated or invalited) * Normal pages (order-0 and anon-THP) - If they are clean and unmapped page cache pages, we invalidate then by means of invalidate_inode_page(). - If they are mapped/dirty, we do the isolate-and-migrate dance. Either way, do not call put_page directly from those paths. Instead, we keep the page and send it to page_set_poison to perform the right handling. page_set_poison sets the HWPoison flag and does the last put_page. This call to put_page is mainly to be able to call __page_cache_release, since this function is not exported. Down the chain, we placed a check for HWPoison page in free_pages_prepare, that just skips any poisoned page, so those pages do not end up in any pcplist/freelist. After that, we set the refcount on the page to 1 and we increment the poisoned pages counter. We could do as we do for free pages: 1) wait until the page hits buddy's freelists 2) take it off 3) flag it The problem is that we could race with an allocation, so by the time we want to take the page off the buddy, the page is already allocated, so we cannot soft-offline it. This is not fatal of course, but if it is better if we can close the race as does not require a lot of code. * Hugetlb pages - We isolate-and-migrate them After the migration has been successful, we call dissolve_free_huge_page, and we set HWPoison on the page if we succeed. Hugetlb has a slightly different handling though. While for non-hugetlb pages we cared about closing the race with an allocation, doing so for hugetlb pages requires quite some additional code (we would need to hook in free_huge_page and some other places). So I decided to not make the code overly complicated and just fail normally if the page we allocated in the meantime. Because of the way we handle now in-use pages, we no longer need the put-as-isolation-migratetype dance, that was guarding for poisoned pages to end up in pcplists. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- include/linux/page-flags.h | 5 ----- mm/memory-failure.c | 44 +++++++++++++------------------------- mm/migrate.c | 11 +++------- mm/page_alloc.c | 31 +++------------------------ 4 files changed, 21 insertions(+), 70 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/include/linux/page-flags.h v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/page-flags.h index 9fa5d4e2d69a..d1df51ed6eeb 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/include/linux/page-flags.h +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/page-flags.h @@ -422,14 +422,9 @@ PAGEFLAG_FALSE(Uncached) PAGEFLAG(HWPoison, hwpoison, PF_ANY) TESTSCFLAG(HWPoison, hwpoison, PF_ANY) #define __PG_HWPOISON (1UL << PG_hwpoison) -extern bool set_hwpoison_free_buddy_page(struct page *page); extern bool take_page_off_buddy(struct page *page); #else PAGEFLAG_FALSE(HWPoison) -static inline bool set_hwpoison_free_buddy_page(struct page *page) -{ - return 0; -} #define __PG_HWPOISON 0 #endif diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index d79e756a97be..f744eb90c15c 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -78,9 +78,12 @@ EXPORT_SYMBOL_GPL(hwpoison_filter_dev_minor); EXPORT_SYMBOL_GPL(hwpoison_filter_flags_mask); EXPORT_SYMBOL_GPL(hwpoison_filter_flags_value); -static void page_handle_poison(struct page *page) +static void page_handle_poison(struct page *page, bool release) { + SetPageHWPoison(page); + if (release) + put_page(page); page_ref_inc(page); num_poisoned_pages_inc(); } @@ -1757,19 +1760,13 @@ static int soft_offline_huge_page(struct page *page) ret = -EIO; } else { /* - * We set PG_hwpoison only when the migration source hugepage - * was successfully dissolved, because otherwise hwpoisoned - * hugepage remains on free hugepage list, then userspace will - * find it as SIGBUS by allocation failure. That's not expected - * in soft-offlining. + * We set PG_hwpoison only when we were able to take the page + * off the buddy. */ - ret = dissolve_free_huge_page(page); - if (!ret) { - if (set_hwpoison_free_buddy_page(page)) - num_poisoned_pages_inc(); - else - ret = -EBUSY; - } + if (!dissolve_free_huge_page(page) && take_page_off_buddy(page)) + page_handle_poison(page, false); + else + ret = -EBUSY; } return ret; } @@ -1804,10 +1801,8 @@ static int __soft_offline_page(struct page *page) * would need to fix isolation locking first. */ if (ret == 1) { - put_page(page); pr_info("soft_offline: %#lx: invalidated\n", pfn); - SetPageHWPoison(page); - num_poisoned_pages_inc(); + page_handle_poison(page, true); return 0; } @@ -1838,7 +1833,9 @@ static int __soft_offline_page(struct page *page) list_add(&page->lru, &pagelist); ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, MIGRATE_SYNC, MR_MEMORY_FAILURE); - if (ret) { + if (!ret) { + page_handle_poison(page, true); + } else { if (!list_empty(&pagelist)) putback_movable_pages(&pagelist); @@ -1857,27 +1854,16 @@ static int __soft_offline_page(struct page *page) static int soft_offline_in_use_page(struct page *page) { int ret; - int mt; struct page *hpage = compound_head(page); if (!PageHuge(page) && PageTransHuge(hpage)) if (try_to_split_thp_page(page, "soft offline") < 0) return -EBUSY; - /* - * Setting MIGRATE_ISOLATE here ensures that the page will be linked - * to free list immediately (not via pcplist) when released after - * successful page migration. Otherwise we can't guarantee that the - * page is really free after put_page() returns, so - * set_hwpoison_free_buddy_page() highly likely fails. - */ - mt = get_pageblock_migratetype(page); - set_pageblock_migratetype(page, MIGRATE_ISOLATE); if (PageHuge(page)) ret = soft_offline_huge_page(page); else ret = __soft_offline_page(page); - set_pageblock_migratetype(page, mt); return ret; } @@ -1886,7 +1872,7 @@ static int soft_offline_free_page(struct page *page) int rc = -EBUSY; if (!dissolve_free_huge_page(page) && take_page_off_buddy(page)) { - page_handle_poison(page); + page_handle_poison(page, false); rc = 0; } diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/migrate.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/migrate.c index c95912f74fe2..4381f76becee 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/migrate.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/migrate.c @@ -1255,16 +1255,11 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page, */ if (newpage && PageTransHuge(newpage)) thp_pmd_migration_success(true); - put_page(page); - if (reason == MR_MEMORY_FAILURE) { + if (reason != MR_MEMORY_FAILURE) /* - * Set PG_HWPoison on just freed page - * intentionally. Although it's rather weird, - * it's how HWPoison flag works at the moment. + * We release the page in page_handle_poison. */ - if (set_hwpoison_free_buddy_page(page)) - num_poisoned_pages_inc(); - } + put_page(page); } else { if (rc != -EAGAIN) { if (likely(!__PageMovable(page))) { diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/page_alloc.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/page_alloc.c index 3b145bceb477..5fbd28d63d60 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/page_alloc.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/page_alloc.c @@ -1175,6 +1175,9 @@ static __always_inline bool free_pages_prepare(struct page *page, VM_BUG_ON_PAGE(PageTail(page), page); + if (unlikely(PageHWPoison(page)) && !order) + return false; + trace_mm_page_free(page, order); /* @@ -8848,32 +8851,4 @@ bool take_page_off_buddy(struct page *page) spin_unlock_irqrestore(&zone->lock, flags); return ret; } - -/* - * Set PG_hwpoison flag if a given page is confirmed to be a free page. This - * test is performed under the zone lock to prevent a race against page - * allocation. - */ -bool set_hwpoison_free_buddy_page(struct page *page) -{ - struct zone *zone = page_zone(page); - unsigned long pfn = page_to_pfn(page); - unsigned long flags; - unsigned int order; - bool hwpoisoned = false; - - spin_lock_irqsave(&zone->lock, flags); - for (order = 0; order < MAX_ORDER; order++) { - struct page *page_head = page - (pfn & ((1 << order) - 1)); - - if (PageBuddy(page_head) && page_order(page_head) >= order) { - if (!TestSetPageHWPoison(page)) - hwpoisoned = true; - break; - } - } - spin_unlock_irqrestore(&zone->lock, flags); - - return hwpoisoned; -} #endif From patchwork Wed Jun 24 15:01:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623401 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8974060D for ; Wed, 24 Jun 2020 15:04:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 457E3206C0 for ; Wed, 24 Jun 2020 15:04:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CLG1GV1D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 457E3206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4284C6B002C; Wed, 24 Jun 2020 11:04:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3D8DF6B002D; Wed, 24 Jun 2020 11:04:15 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EFA56B002E; Wed, 24 Jun 2020 11:04:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0227.hostedemail.com [216.40.44.227]) by kanga.kvack.org (Postfix) with ESMTP id 17BBF6B002C for ; Wed, 24 Jun 2020 11:04:15 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C849A181AC9C6 for ; Wed, 24 Jun 2020 15:04:14 +0000 (UTC) X-FDA: 76964426028.12.slope47_26135d926e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 5EBD31801599D for ; Wed, 24 Jun 2020 15:02:24 +0000 (UTC) X-Spam-Summary: 1,0,0,e542fa24c7ae9f59,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:1:2:41:69:355:379:541:800:960:966:973:982:988:989:1260:1345:1359:1437:1605:1730:1747:1777:1792:2194:2196:2198:2199:2200:2201:2393:2559:2562:2693:2731:2899:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3872:3874:4052:4250:4321:4385:5007:6119:6261:6653:7576:7903:8957:9010:9413:9592:11026:11232:11473:11658:11914:12043:12114:12291:12296:12297:12438:12517:12519:12555:12679:12683:12740:12895:13180:13229:13255:14096:14394:21060:21080:21094:21323:21324:21444:21451:21627:21666:21740:21809:21939:21987:21990:22119:30012:30034:30054:30070,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yg71qiqq5ucf8i317sojy1f3rxeycbk45giedubzt1y4eberk5jwta65eqeen.dxfbhxfoid7oyxsjxdqdr3m86q4y7x5kjuypq9uu1r9qgyf99mb4e1gfy5gwgcr.w-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rul es:0:1:0 X-HE-Tag: slope47_26135d926e45 X-Filterd-Recvd-Size: 12121 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:02:23 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id e9so1537944pgo.9 for ; Wed, 24 Jun 2020 08:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kHsJMTyrzGs/lMla3mx1ITOEfxJev53X7nb3oA+rEkM=; b=CLG1GV1DsEigRZMeWoVq0PQGyE0P9pnkkp16DsSuPJjTZ88qosmUXKaw/UshA2rUin JjGRjRUDlBDaoZTCkWmQsQWwD+h2so/vHqeeBb2uFauv+K6JOl2EQDewJK83Af5xy3Mt WzyidjOLhJW72hE82Ikbsi9mbzF7uQ9xtWwJgO/CQySQcZ99GGTL+IdtzmFR039pZbxq 8gJhvt+A0agagm2CqrO92jbJwhhgPLExL8dR0XEpUkcZe9JfIgYFTKELV3m4i4hi8/ng oH20Mg5hMUp4HcVl6yP0pCV3yHtqWSxj4izzU3s0uX8mbYoOPSt0Q9tnGRYMN50vtRwS y6oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kHsJMTyrzGs/lMla3mx1ITOEfxJev53X7nb3oA+rEkM=; b=U1VAfICF2PJ5JiBpuTGlQnQjT3Gm0Nm/X8NBknw7/GXn0fXV79f1lAVSBVFCCsKabj PVHrMa/90XeHmxtTWC3zOiQA/P3qjmpvx2DfOPlPsVqA1kCGV0fmhojGIpyX3ybzYOHg Wi8KQq7Hm4C6QEEGuLS6kdvsEuC8UfgMh5GRgmu5z8tHCk3r4tSaJ3f6vYEQIu63kPe/ paBdj18dLhISf2FMfX/WyhjNvNEwyQSkTk7oADGPrOZA2oC1YGF4LjV4jYBOevipkT2w WLTXRyEbos6AoYuD++O5QsVFDcgjlMRB/5oaMIIEsB2PNJe7U9gEljgG67VKIfZ3GYO7 QyOw== X-Gm-Message-State: AOAM53247HMJUXT0MWXazE5ljZqPQly8j5B+eNvoswAoGy6ndVq5bNIL oQc50NOk72nbluJs7JRAT+k3kNFyvg== X-Google-Smtp-Source: ABdhPJyVcH1CLgJOJlA115WQq27melIISXx96Q/p3lqjSymZwNPjBcIAe1+YUVrGwwbNsRcL4r3PXg== X-Received: by 2002:a65:4807:: with SMTP id h7mr22759246pgs.123.1593010942497; Wed, 24 Jun 2020 08:02:22 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:02:22 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 13/15] mm,hwpoison: Refactor soft_offline_huge_page and __soft_offline_page Date: Wed, 24 Jun 2020 15:01:35 +0000 Message-Id: <20200624150137.7052-14-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 5EBD31801599D X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: From: Oscar Salvador Merging soft_offline_huge_page and __soft_offline_page let us get rid of quite some duplicated code, and makes the code much easier to follow. Now, __soft_offline_page will handle both normal and hugetlb pages. Note that move put_page() block to the beginning of page_handle_poison() with drain_all_pages() in order to make sure that the target page is freed and sent into free list to make take_page_off_buddy() work properly. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- ChangeLog v2 -> v3: - use page_is_file_lru() instead of page_is_file_cache(), - add description about put_page() and drain_all_pages(). - fix coding style warnings by checkpatch.pl --- mm/memory-failure.c | 185 ++++++++++++++++++++------------------------ 1 file changed, 86 insertions(+), 99 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index f744eb90c15c..22c904f6d17a 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -78,14 +78,36 @@ EXPORT_SYMBOL_GPL(hwpoison_filter_dev_minor); EXPORT_SYMBOL_GPL(hwpoison_filter_flags_mask); EXPORT_SYMBOL_GPL(hwpoison_filter_flags_value); -static void page_handle_poison(struct page *page, bool release) +static bool page_handle_poison(struct page *page, bool hugepage_or_freepage, bool release) { + if (release) { + put_page(page); + drain_all_pages(page_zone(page)); + } + + if (hugepage_or_freepage) { + /* + * Doing this check for free pages is also fine since dissolve_free_huge_page + * returns 0 for non-hugetlb pages as well. + */ + if (dissolve_free_huge_page(page) || !take_page_off_buddy(page)) + /* + * The hugetlb page can end up being enqueued back into + * the freelists by means of: + * unmap_and_move_huge_page + * putback_active_hugepage + * put_page->free_huge_page + * enqueue_huge_page + * If this happens, we might lose the race against an allocation. + */ + return false; + } SetPageHWPoison(page); - if (release) - put_page(page); page_ref_inc(page); num_poisoned_pages_inc(); + + return true; } static int hwpoison_filter_dev(struct page *p) @@ -1718,63 +1740,52 @@ static int get_any_page(struct page *page, unsigned long pfn) return ret; } -static int soft_offline_huge_page(struct page *page) +static bool isolate_page(struct page *page, struct list_head *pagelist) { - int ret; - unsigned long pfn = page_to_pfn(page); - struct page *hpage = compound_head(page); - LIST_HEAD(pagelist); + bool isolated = false; + bool lru = PageLRU(page); + + if (PageHuge(page)) { + isolated = isolate_huge_page(page, pagelist); + } else { + if (lru) + isolated = !isolate_lru_page(page); + else + isolated = !isolate_movable_page(page, ISOLATE_UNEVICTABLE); + + if (isolated) + list_add(&page->lru, pagelist); - /* - * This double-check of PageHWPoison is to avoid the race with - * memory_failure(). See also comment in __soft_offline_page(). - */ - lock_page(hpage); - if (PageHWPoison(hpage)) { - unlock_page(hpage); - put_page(hpage); - pr_info("soft offline: %#lx hugepage already poisoned\n", pfn); - return -EBUSY; } - unlock_page(hpage); - ret = isolate_huge_page(hpage, &pagelist); + if (isolated && lru) + inc_node_page_state(page, NR_ISOLATED_ANON + + page_is_file_lru(page)); + /* - * get_any_page() and isolate_huge_page() takes a refcount each, - * so need to drop one here. + * If we succeed to isolate the page, we grabbed another refcount on + * the page, so we can safely drop the one we got from get_any_pages(). + * If we failed to isolate the page, it means that we cannot go further + * and we will return an error, so drop the reference we got from + * get_any_pages() as well. */ - put_page(hpage); - if (!ret) { - pr_info("soft offline: %#lx hugepage failed to isolate\n", pfn); - return -EBUSY; - } - - ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, - MIGRATE_SYNC, MR_MEMORY_FAILURE); - if (ret) { - pr_info("soft offline: %#lx: hugepage migration failed %d, type %lx (%pGp)\n", - pfn, ret, page->flags, &page->flags); - if (!list_empty(&pagelist)) - putback_movable_pages(&pagelist); - if (ret > 0) - ret = -EIO; - } else { - /* - * We set PG_hwpoison only when we were able to take the page - * off the buddy. - */ - if (!dissolve_free_huge_page(page) && take_page_off_buddy(page)) - page_handle_poison(page, false); - else - ret = -EBUSY; - } - return ret; + put_page(page); + return isolated; } +/* + * __soft_offline_page handles hugetlb-pages and non-hugetlb pages. + * If the page is a non-dirty unmapped page-cache page, it simply invalidates. + * If the page is mapped, it migrates the contents over. + */ static int __soft_offline_page(struct page *page) { - int ret; + int ret = 0; unsigned long pfn = page_to_pfn(page); + struct page *hpage = compound_head(page); + const char *msg_page[] = {"page", "hugepage"}; + bool huge = PageHuge(page); + LIST_HEAD(pagelist); /* * Check PageHWPoison again inside page lock because PageHWPoison @@ -1783,98 +1794,74 @@ static int __soft_offline_page(struct page *page) * so there's no race between soft_offline_page() and memory_failure(). */ lock_page(page); - wait_on_page_writeback(page); + if (!PageHuge(page)) + wait_on_page_writeback(page); if (PageHWPoison(page)) { unlock_page(page); put_page(page); pr_info("soft offline: %#lx page already poisoned\n", pfn); return -EBUSY; } - /* - * Try to invalidate first. This should work for - * non dirty unmapped page cache pages. - */ - ret = invalidate_inode_page(page); + + if (!PageHuge(page)) + /* + * Try to invalidate first. This should work for + * non dirty unmapped page cache pages. + */ + ret = invalidate_inode_page(page); unlock_page(page); + /* * RED-PEN would be better to keep it isolated here, but we * would need to fix isolation locking first. */ - if (ret == 1) { + if (ret) { pr_info("soft_offline: %#lx: invalidated\n", pfn); - page_handle_poison(page, true); + page_handle_poison(page, false, true); return 0; } - /* - * Simple invalidation didn't work. - * Try to migrate to a new page instead. migrate.c - * handles a large number of cases for us. - */ - if (PageLRU(page)) - ret = isolate_lru_page(page); - else - ret = isolate_movable_page(page, ISOLATE_UNEVICTABLE); - /* - * Drop page reference which is came from get_any_page() - * successful isolate_lru_page() already took another one. - */ - put_page(page); - if (!ret) { - LIST_HEAD(pagelist); - /* - * After isolated lru page, the PageLRU will be cleared, - * so use !__PageMovable instead for LRU page's mapping - * cannot have PAGE_MAPPING_MOVABLE. - */ - if (!__PageMovable(page)) - inc_node_page_state(page, NR_ISOLATED_ANON + - page_is_file_lru(page)); - list_add(&page->lru, &pagelist); + if (isolate_page(hpage, &pagelist)) { ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, MIGRATE_SYNC, MR_MEMORY_FAILURE); if (!ret) { - page_handle_poison(page, true); + bool release = !huge; + + if (!page_handle_poison(page, true, release)) + ret = -EBUSY; } else { if (!list_empty(&pagelist)) putback_movable_pages(&pagelist); - pr_info("soft offline: %#lx: migration failed %d, type %lx (%pGp)\n", - pfn, ret, page->flags, &page->flags); + + pr_info("soft offline: %#lx: %s migration failed %d, type %lx (%pGp)\n", + pfn, msg_page[huge], ret, page->flags, &page->flags); if (ret > 0) ret = -EIO; } } else { - pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx (%pGp)\n", - pfn, ret, page_count(page), page->flags, &page->flags); + pr_info("soft offline: %#lx: %s isolation failed: %d, page count %d, type %lx (%pGp)\n", + pfn, msg_page[huge], ret, page_count(page), page->flags, &page->flags); } return ret; } static int soft_offline_in_use_page(struct page *page) { - int ret; struct page *hpage = compound_head(page); if (!PageHuge(page) && PageTransHuge(hpage)) if (try_to_split_thp_page(page, "soft offline") < 0) return -EBUSY; - - if (PageHuge(page)) - ret = soft_offline_huge_page(page); - else - ret = __soft_offline_page(page); - return ret; + return __soft_offline_page(page); } static int soft_offline_free_page(struct page *page) { - int rc = -EBUSY; + int rc = 0; - if (!dissolve_free_huge_page(page) && take_page_off_buddy(page)) { - page_handle_poison(page, false); - rc = 0; - } + if (!page_handle_poison(page, true, false)) + rc = -EBUSY; return rc; } From patchwork Wed Jun 24 15:01:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623405 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93DEE912 for ; Wed, 24 Jun 2020 15:04:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5766F206C0 for ; Wed, 24 Jun 2020 15:04:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mPAONOoO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5766F206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 53B956B002F; Wed, 24 Jun 2020 11:04:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 513946B0031; Wed, 24 Jun 2020 11:04:34 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B42A6B0032; Wed, 24 Jun 2020 11:04:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0147.hostedemail.com [216.40.44.147]) by kanga.kvack.org (Postfix) with ESMTP id 214996B002F for ; Wed, 24 Jun 2020 11:04:34 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C8DD7180AC16E for ; Wed, 24 Jun 2020 15:04:33 +0000 (UTC) X-FDA: 76964426826.22.scale29_400576726e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id DA5F418039609 for ; Wed, 24 Jun 2020 15:02:29 +0000 (UTC) X-Spam-Summary: 1,0,0,180bb8ef8b1de359,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1535:1542:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2693:2898:2899:3138:3139:3140:3141:3142:3353:3865:3867:3868:3870:3871:3872:3874:4321:4605:5007:6119:6261:6653:7576:7903:8957:9121:9413:9592:10004:11026:11233:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:12986:13166:13229:13255:14181:14394:14721:21060:21080:21324:21444:21611:21627:21666:21795:21990:22119:30003:30054:30070,0,RBL:209.85.216.65:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04yrwfjjnwnomhetjnp6pwxf1y8r7opwufk344gf776oe8mqznwstuswce6gc5u.765gipr8cqueafjdjwytnmcd3bqup5amw3dosa49rp7pnp676f15zkwzio6kknu.1-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: scale29_400576726e45 X-Filterd-Recvd-Size: 5515 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:02:27 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id ne5so1267653pjb.5 for ; Wed, 24 Jun 2020 08:02:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J0Xeovjt/xfdRY3CY7rSgO7sQOzE+w1RTWn+OXKgogk=; b=mPAONOoOMCz3IzPvpOtPAvFkSpNOWWK64tYeTcGp6deJ7CGiQdTIbJCV2Oq5KqScuO ADRvQ4+VVqQBfUd0xqxLtL5HOjaJKhJGpU/WYe8APPid8XYqspwYo1OuZqTS7Nm22CiQ dmociYAaoYOUH0EqVKScWSV8fzliM2Gt2mSfUAFL8rSsvHv1vAxPpTXX6XhyMO0wgIz0 2QmyCW3M3bAByYly33meuPj7eq64fO2j+tSP7MDEmaZ76LbcUiEIDIcU4llqohRiD/QA O54Zk7e6ZJyVtnWggGSBqR1lqlmXON+xERUiXIGJU73FIak4foWAfIvj0FdlrHopRmji Z0GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=J0Xeovjt/xfdRY3CY7rSgO7sQOzE+w1RTWn+OXKgogk=; b=F1X5ley2wYzBOTsQdzQ/+8oRSWK6Bcx5uiiFb9wHHGxE2VMlO1NP5xSgh0D8z7WLqF OgfRXPlPOuVIuI8oLX9dfeGb47+W1d0qFG7UcjyqSKw9M+nywNe1sO+N1vMpUYCFRXKA 46UR4ECA7sWm8ixENO5aqcjpNv8p1/LH1X2ufaV/HD90PfMRrioVoN06oaZVnOJKkhD6 bn+2bNiqdfnJmkLZMjeegz2oGIY9ZAfzbTKSUeUD2Gi/uYXTFngnWwIKAbFoSO3gOiYy /hYKgfjq3NtikG1ApCG0qeUnOY5K5IsegON/BxqUtQgihySDOlsbVLa5AxS6Hq02SAs1 ulmQ== X-Gm-Message-State: AOAM531zdkMtRrhAq8U3Mds21viAy60+54ZUeKp5aGxUGCvPseKgWDHi jX4rgo9JDcixEcjGAZenMhB1ukDuiw== X-Google-Smtp-Source: ABdhPJw6MfmyFpw8wUaLuJ/Vb231TF9GIf25hqGNAuaS+lTOsKaFPSQMkwSVd0NnleNPPJ4y5vKcQg== X-Received: by 2002:a17:90a:e801:: with SMTP id i1mr28012066pjy.79.1593010945548; Wed, 24 Jun 2020 08:02:25 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:02:25 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 14/15] mm,hwpoison: Return 0 if the page is already poisoned in soft-offline Date: Wed, 24 Jun 2020 15:01:36 +0000 Message-Id: <20200624150137.7052-15-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: DA5F418039609 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: From: Oscar Salvador Currently, there is an inconsistency when calling soft-offline from different paths on a page that is already poisoned. 1) madvise: madvise_inject_error skips any poisoned page and continues the loop. If that was the only page to madvise, it returns 0. 2) /sys/devices/system/memory/: When calling soft_offline_page_store()->soft_offline_page(), we return -EBUSY in case the page is already poisoned. This is inconsistent with a) the above example and b) memory_failure, where we return 0 if the page was poisoned. Fix this by dropping the PageHWPoison() check in madvise_inject_error, and let soft_offline_page return 0 if it finds the page already poisoned. Please, note that this represents a user-api change, since now the return error when calling soft_offline_page_store()->soft_offline_page() will be different. Signed-off-by: Oscar Salvador Signed-off-by: Naoya Horiguchi --- mm/madvise.c | 3 --- mm/memory-failure.c | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/madvise.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c index 2b5080253406..b59bbd6c9982 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/madvise.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/madvise.c @@ -902,9 +902,6 @@ static int madvise_inject_error(int behavior, */ 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); diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index 22c904f6d17a..9ad3198a3954 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -1800,7 +1800,7 @@ static int __soft_offline_page(struct page *page) unlock_page(page); put_page(page); pr_info("soft offline: %#lx page already poisoned\n", pfn); - return -EBUSY; + return 0; } if (!PageHuge(page)) @@ -1901,7 +1901,7 @@ int soft_offline_page(unsigned long pfn) if (PageHWPoison(page)) { pr_info("soft offline: %#lx page already poisoned\n", pfn); - return -EBUSY; + return 0; } get_online_mems(); From patchwork Wed Jun 24 15:01:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 11623403 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AFE0912 for ; Wed, 24 Jun 2020 15:04:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 576E9206C0 for ; Wed, 24 Jun 2020 15:04:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rl9izeas" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 576E9206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8E3946B002D; Wed, 24 Jun 2020 11:04:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 892BA6B002F; Wed, 24 Jun 2020 11:04:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 783966B0030; Wed, 24 Jun 2020 11:04:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id 607486B002D for ; Wed, 24 Jun 2020 11:04:33 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 192D121254 for ; Wed, 24 Jun 2020 15:04:33 +0000 (UTC) X-FDA: 76964426826.12.plane56_4a0db3626e45 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 4DB3018024BEF for ; Wed, 24 Jun 2020 15:02:35 +0000 (UTC) X-Spam-Summary: 1,0,0,27f0407dd1825a82,d41d8cd98f00b204,nao.horiguchi@gmail.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1345:1359:1437:1535:1542:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2899:3138:3139:3140:3141:3142:3353:3867:3871:3872:3874:4250:4321:4385:4605:5007:6261:6653:7576:8660:8957:9413:10004:11026:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12740:12895:13148:13230:14093:14181:14394:14721:21060:21080:21094:21212:21323:21324:21444:21627:21666:21939:21990:22119:30054,0,RBL:209.85.214.195:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04y8jj4yssqf7tjo1mwnku6eyem66opbydps57nqhwnh1ycc4y9zccg475xi6g8.oc9oap447o9m5u3ygbhstmbgdanss7p6jzf7aods9yjsfag6wricsjn4wh38f5w.r-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: plane56_4a0db3626e45 X-Filterd-Recvd-Size: 5999 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 15:02:29 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id k1so1168964pls.2 for ; Wed, 24 Jun 2020 08:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JWnneQzXfI0UCqfkUaeoAs3ig549rm/MnU8+no9mpQ8=; b=Rl9izeasMTckdt53HqfGTVXn8hAB7zTLsVPwhL7+DoOPgmHJ1jZcR0+vO+ug/jMR8p 25vwgeyf8U4dsLT36Ix4duFc4Xdof7G2CRr2xeT6SLQ1oW7b3xgbKjJjK7xoJ3qDsRa1 7adwN/K8ocUYxYMT4i34qZew5jTojr2t2rUUEaIEoWhNQwbDjENmYFLC0iOTJH4cz2Au YQHtwNAqlbccLU3Q//01FIhA8ZaSS8xKarSyfsautTo8m90ExIUerNO1evzIH70Da7Bu nXjpAuFY81AEyUX+MZ9NgJg/EE5HUVE3UYUSi1XMQFXN6jgozXTKUO4QpslpVQoXoKzc 8Log== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JWnneQzXfI0UCqfkUaeoAs3ig549rm/MnU8+no9mpQ8=; b=TPOFrDE7PGKlSHanoKe6Z8dKZ7WW0vESABLCGss+UemfK62lXip9wNgQb0xc7/IEHm Tr6tiWe0B1xV43geEhAWT0KiYtqstmacewBRWmUNF8xg4vuqEQcYr/iDttirK9p8jTso 6V6rAPfss53IraDvdGZrvM0v9JpdGTLuvne0+GD/DluHIoScS5ArRJKGvBI4xQEPdlQm 0+xlrR8hNr5sxZ3wtgW9P5gIdUXDjBwO75USPJStRXZbOPpJDeVOnlm6Qllq3CCABk+v k/yj1J2L1dzJSfTJG4Ycr+7p86qSj3mKOQQFiq+9axnq10qXtHOX9W4b/gz3pXdAyW6n D5Hg== X-Gm-Message-State: AOAM5303Ew0qmIrf/+OLmd3LCRWKQDgZJ7zjtGXUhy42wofO3XKXS9vT NqCVFHfBfcIP1E7JBCOdja+M/OVh2w== X-Google-Smtp-Source: ABdhPJxl1PHw4LkPk6lT5aYG/XIcClNITVvyBSM5EkGGToos6HlxyHE06skpVZArpn/F/RPE11cC0A== X-Received: by 2002:a17:90a:3608:: with SMTP id s8mr29753490pjb.86.1593010948525; Wed, 24 Jun 2020 08:02:28 -0700 (PDT) Received: from ip-172-31-41-194.ap-northeast-1.compute.internal (ec2-52-199-21-241.ap-northeast-1.compute.amazonaws.com. [52.199.21.241]) by smtp.gmail.com with ESMTPSA id i125sm17013705pgd.21.2020.06.24.08.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2020 08:02:28 -0700 (PDT) From: nao.horiguchi@gmail.com To: linux-mm@kvack.org Cc: mhocko@kernel.org, akpm@linux-foundation.org, mike.kravetz@oracle.com, osalvador@suse.de, tony.luck@intel.com, david@redhat.com, aneesh.kumar@linux.vnet.ibm.com, zeil@yandex-team.ru, naoya.horiguchi@nec.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 15/15] mm,hwpoison: introduce MF_MSG_UNSPLIT_THP Date: Wed, 24 Jun 2020 15:01:37 +0000 Message-Id: <20200624150137.7052-16-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624150137.7052-1-nao.horiguchi@gmail.com> References: <20200624150137.7052-1-nao.horiguchi@gmail.com> X-Rspamd-Queue-Id: 4DB3018024BEF X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: From: Naoya Horiguchi memory_failure() is supposed to call action_result() when it handles a memory error event, but there's one missing case. So let's add it. I find that include/ras/ras_event.h has some other MF_MSG_* undefined, so this patch also adds them. Signed-off-by: Naoya Horiguchi --- include/linux/mm.h | 1 + include/ras/ras_event.h | 3 +++ mm/memory-failure.c | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git v5.8-rc1-mmots-2020-06-20-21-44/include/linux/mm.h v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/mm.h index d708033c50c0..10ee48f05f68 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/include/linux/mm.h +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/include/linux/mm.h @@ -3033,6 +3033,7 @@ enum mf_action_page_type { MF_MSG_BUDDY, MF_MSG_BUDDY_2ND, MF_MSG_DAX, + MF_MSG_UNSPLIT_THP, MF_MSG_UNKNOWN, }; diff --git v5.8-rc1-mmots-2020-06-20-21-44/include/ras/ras_event.h v5.8-rc1-mmots-2020-06-20-21-44_patched/include/ras/ras_event.h index 36c5c5e38c1d..0bdbc0d17d2f 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/include/ras/ras_event.h +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/include/ras/ras_event.h @@ -361,6 +361,7 @@ TRACE_EVENT(aer_event, EM ( MF_MSG_POISONED_HUGE, "huge page already hardware poisoned" ) \ EM ( MF_MSG_HUGE, "huge page" ) \ EM ( MF_MSG_FREE_HUGE, "free huge page" ) \ + EM ( MF_MSG_NON_PMD_HUGE, "non-pmd-sized huge page" ) \ EM ( MF_MSG_UNMAP_FAILED, "unmapping failed page" ) \ EM ( MF_MSG_DIRTY_SWAPCACHE, "dirty swapcache page" ) \ EM ( MF_MSG_CLEAN_SWAPCACHE, "clean swapcache page" ) \ @@ -373,6 +374,8 @@ TRACE_EVENT(aer_event, EM ( MF_MSG_TRUNCATED_LRU, "already truncated LRU page" ) \ EM ( MF_MSG_BUDDY, "free buddy page" ) \ EM ( MF_MSG_BUDDY_2ND, "free buddy page (2nd try)" ) \ + EM ( MF_MSG_DAX, "dax page" ) \ + EM ( MF_MSG_UNSPLIT_THP, "unsplit thp" ) \ EMe ( MF_MSG_UNKNOWN, "unknown page" ) /* diff --git v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c index 9ad3198a3954..e57cfe0606f5 100644 --- v5.8-rc1-mmots-2020-06-20-21-44/mm/memory-failure.c +++ v5.8-rc1-mmots-2020-06-20-21-44_patched/mm/memory-failure.c @@ -586,6 +586,7 @@ static const char * const action_page_types[] = { [MF_MSG_BUDDY] = "free buddy page", [MF_MSG_BUDDY_2ND] = "free buddy page (2nd try)", [MF_MSG_DAX] = "dax page", + [MF_MSG_UNSPLIT_THP] = "unsplit thp", [MF_MSG_UNKNOWN] = "unknown page", }; @@ -1376,8 +1377,10 @@ int memory_failure(unsigned long pfn, int flags) } if (PageTransHuge(hpage)) { - if (try_to_split_thp_page(p, "Memory Failure") < 0) + if (try_to_split_thp_page(p, "Memory Failure") < 0) { + action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED); return -EBUSY; + } VM_BUG_ON_PAGE(!page_count(p), p); }