From patchwork Wed Jul 4 21:40:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10507645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 72291603D7 for ; Wed, 4 Jul 2018 21:50:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 687F828DAF for ; Wed, 4 Jul 2018 21:50:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D15728DAA; Wed, 4 Jul 2018 21:50:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C499928CD3 for ; Wed, 4 Jul 2018 21:50:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F9676B026B; Wed, 4 Jul 2018 17:50:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3A4AA6B026C; Wed, 4 Jul 2018 17:50:55 -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 2BB336B026D; Wed, 4 Jul 2018 17:50:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id E06B56B026B for ; Wed, 4 Jul 2018 17:50:54 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id y26-v6so3456849pfn.14 for ; Wed, 04 Jul 2018 14:50:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=xSn5dkHBAOfaboDsB4AS2HLoIc6TRtgxdKk1ngUHG0U=; b=UsnPlAfX1D9K5E+tWSFgUF2lBInAIpGxz1oop3CUoGNsmnV4YIssB+mEhvGAVQ6ujq cLi0EF8bSd68hBlAH7vkS/aHd1DYnheWIIYi8N2uqYqEbXYiXW9pByHxSPofXh0AwxRH waOsuDNd9UqtWNs1AaTc9fm3wufmShiL6l8v/X4bEvkghj5JUhv7mumPFpONlJFg4b+c W/g5ys82xC0jljx5mDN/Tbi+1wMBzZleXBzF8NXbMmP3NCd53yuhmK1wIV6PMxIjCUPo 1HtnsJ/sw/7vn978rsnbeQ02p6ZxCLYhyykLj/13jAEPea0Rfpcp1EKPWpxDMWHBhYuQ tk8w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APt69E1Ql7ANjIgbXGfhIRiPuszPrs5hjZk82eei8JZDrxtJB3eCL0uZ uxcaABZ+jS6AkHznmBEz2nwP7mC55qi9NqQ+Oa5ACScS2c7auOZzRlBWQVwxU7u/znfaiAsyG3D 155U9fPqNWPwNN1xdh4aeuCqIgbhr/j4p2QcYTzIp6mms+fhaTP7Jd7XsQa0g/0SXSA== X-Received: by 2002:a17:902:758c:: with SMTP id j12-v6mr3556795pll.195.1530741054595; Wed, 04 Jul 2018 14:50:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdVo8SGfauBpjFUtDvwO7yuXwuAMoe3RxQS9q893bIMKsQwpMrZjLQQgP7rDt9fayNU4gEa X-Received: by 2002:a17:902:758c:: with SMTP id j12-v6mr3556763pll.195.1530741053590; Wed, 04 Jul 2018 14:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530741053; cv=none; d=google.com; s=arc-20160816; b=xZmQ2WML2kHfFhTzQ94f5jBAEU6FgQG6Z9UMC7/GsM0VD3AeVkKB4qtuBLVkXjCQXL /XuThKEbyCC0SD+FHTMC5KMnbxGPSyQ7QJatDg3pzS06/KMKGN8cd8imkLI7JBlWHWTE YQnStZirrjQmSq6i899uo0BOYxoXQaq+2eLARI97A57JI0Iz16gMHHRXhsMun4yOGKxj vlhqoYQiONcIwyGJdLadUQpYYxGxVaTBN6k0MbVbA9RcdC1MrYHzhAFXLw4ifICeCyfC 77THQLt8owb0qdWIijkYJYHlr4FMCMIfZ8fnbucCdKD+Q1b9Rbgl2mK3b/Kla4/RE44E Pqcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject :arc-authentication-results; bh=xSn5dkHBAOfaboDsB4AS2HLoIc6TRtgxdKk1ngUHG0U=; b=WpXhTn0xpr5Ngjl1VFL1J7tzMsRLL4bUQ9gl5Z2yTBYGETgTwUbwsAgiMgN+ELPYnx zutKTybxIYwNiynYNHxNKTYmAUY1+Emnn1dcW3UbEMdkU/SyQ6yF1aKhtx1Qsvu3p+Ht 0VDL3tvr4tdknKWFFglj0uJrFJx/5W2S6nhpj2xJC3sDMBd8Z6eAVoC4P7RAD15TNsnh H6xnPe90g44Fz+2SqFvg2tRpHi386XgCnDGKaHqKmxFCbr018fVJ6AJLmdCkI+U2rPvX XyurLDO8+dXlVrXsaH15iSktdHaVF5hs2iG5pdWxHb5SfSGppuQkEexdMKDBY8JihyZe vz1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id n6-v6si4351252pgt.268.2018.07.04.14.50.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jul 2018 14:50:53 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) client-ip=192.55.52.115; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 14:50:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,309,1526367600"; d="scan'208";a="68728873" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga004.fm.intel.com with ESMTP; 04 Jul 2018 14:50:52 -0700 Subject: [PATCH v5 06/11] mm, memory_failure: Collect mapping size in collect_procs() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Naoya Horiguchi , hch@lst.de, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jack@suse.cz, ross.zwisler@linux.intel.com Date: Wed, 04 Jul 2018 14:40:55 -0700 Message-ID: <153074045526.27838.11460088022513024933.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153074042316.27838.17319837331947007626.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153074042316.27838.17319837331947007626.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP In preparation for supporting memory_failure() for dax mappings, teach collect_procs() to also determine the mapping size. Unlike typical mappings the dax mapping size is determined by walking page-table entries rather than using the compound-page accounting for THP pages. Cc: Naoya Horiguchi Signed-off-by: Dan Williams Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 81 +++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 9d142b9b86dc..4d70753af59c 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -174,22 +174,51 @@ int hwpoison_filter(struct page *p) EXPORT_SYMBOL_GPL(hwpoison_filter); /* + * Kill all processes that have a poisoned page mapped and then isolate + * the page. + * + * General strategy: + * Find all processes having the page mapped and kill them. + * But we keep a page reference around so that the page is not + * actually freed yet. + * Then stash the page away + * + * There's no convenient way to get back to mapped processes + * from the VMAs. So do a brute-force search over all + * running processes. + * + * Remember that machine checks are not common (or rather + * if they are common you have other problems), so this shouldn't + * be a performance issue. + * + * Also there are some races possible while we get from the + * error detection to actually handle it. + */ + +struct to_kill { + struct list_head nd; + struct task_struct *tsk; + unsigned long addr; + short size_shift; + char addr_valid; +}; + +/* * Send all the processes who have the page mapped a signal. * ``action optional'' if they are not immediately affected by the error * ``action required'' if error happened in current execution context */ -static int kill_proc(struct task_struct *t, unsigned long addr, - unsigned long pfn, struct page *page, int flags) +static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags) { - short addr_lsb; + struct task_struct *t = tk->tsk; + short addr_lsb = tk->size_shift; int ret; pr_err("Memory failure: %#lx: Killing %s:%d due to hardware memory corruption\n", pfn, t->comm, t->pid); - addr_lsb = compound_order(compound_head(page)) + PAGE_SHIFT; if ((flags & MF_ACTION_REQUIRED) && t->mm == current->mm) { - ret = force_sig_mceerr(BUS_MCEERR_AR, (void __user *)addr, + ret = force_sig_mceerr(BUS_MCEERR_AR, (void __user *)tk->addr, addr_lsb, current); } else { /* @@ -198,7 +227,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, * This could cause a loop when the user sets SIGBUS * to SIG_IGN, but hopefully no one will do that? */ - ret = send_sig_mceerr(BUS_MCEERR_AO, (void __user *)addr, + ret = send_sig_mceerr(BUS_MCEERR_AO, (void __user *)tk->addr, addr_lsb, t); /* synchronous? */ } if (ret < 0) @@ -235,35 +264,6 @@ void shake_page(struct page *p, int access) EXPORT_SYMBOL_GPL(shake_page); /* - * Kill all processes that have a poisoned page mapped and then isolate - * the page. - * - * General strategy: - * Find all processes having the page mapped and kill them. - * But we keep a page reference around so that the page is not - * actually freed yet. - * Then stash the page away - * - * There's no convenient way to get back to mapped processes - * from the VMAs. So do a brute-force search over all - * running processes. - * - * Remember that machine checks are not common (or rather - * if they are common you have other problems), so this shouldn't - * be a performance issue. - * - * Also there are some races possible while we get from the - * error detection to actually handle it. - */ - -struct to_kill { - struct list_head nd; - struct task_struct *tsk; - unsigned long addr; - char addr_valid; -}; - -/* * Failure handling: if we can't find or can't kill a process there's * not much we can do. We just print a message and ignore otherwise. */ @@ -292,6 +292,7 @@ static void add_to_kill(struct task_struct *tsk, struct page *p, } tk->addr = page_address_in_vma(p, vma); tk->addr_valid = 1; + tk->size_shift = compound_order(compound_head(p)) + PAGE_SHIFT; /* * In theory we don't have to kill when the page was @@ -317,9 +318,8 @@ static void add_to_kill(struct task_struct *tsk, struct page *p, * Also when FAIL is set do a force kill because something went * wrong earlier. */ -static void kill_procs(struct list_head *to_kill, int forcekill, - bool fail, struct page *page, unsigned long pfn, - int flags) +static void kill_procs(struct list_head *to_kill, int forcekill, bool fail, + unsigned long pfn, int flags) { struct to_kill *tk, *next; @@ -342,8 +342,7 @@ static void kill_procs(struct list_head *to_kill, int forcekill, * check for that, but we need to tell the * process anyways. */ - else if (kill_proc(tk->tsk, tk->addr, - pfn, page, flags) < 0) + else if (kill_proc(tk, pfn, flags) < 0) pr_err("Memory failure: %#lx: Cannot send advisory machine check signal to %s:%d\n", pfn, tk->tsk->comm, tk->tsk->pid); } @@ -1012,7 +1011,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, * any accesses to the poisoned memory. */ forcekill = PageDirty(hpage) || (flags & MF_MUST_KILL); - kill_procs(&tokill, forcekill, !unmap_success, p, pfn, flags); + kill_procs(&tokill, forcekill, !unmap_success, pfn, flags); return unmap_success; }