Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1353078pxb; Wed, 2 Feb 2022 03:04:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFz29OWCWvz9rbGXr6J/thP1USENA72gPwQGx9YtQ1L48eJFTAtUFbaZuWSZIgvshYNWaf X-Received: by 2002:a63:8641:: with SMTP id x62mr23917705pgd.293.1643799864205; Wed, 02 Feb 2022 03:04:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643799864; cv=none; d=google.com; s=arc-20160816; b=bMCBybkUngR9GUXxc2h1fojhdJTWHc6YxRGowjTOH/wYSY1G1d6jQUp0MvsBtzMk7g 1NV7QWRH4i7CqxUX+BhcBuG7E/2mJCKkflh7htuoJdYuHbuyStvPlDhY52U2NzkRjTMf ipI/L/t0nMeE2kz5VhkCLEvq42DiTh+LZ+/0fuqfeiMmmcCRIANqmN5zHdnwlJ5Bt4bV 0DokrqK2UXdLaDIYkZabhLN9JsW/s2smnDKoiQSJteDR177LqbjlIwCUZBMMyu5Pp81M E+DckGssuEXWBH+tbqUgAEztaVTDUYvK3I42a2MKfgK2DBsLgO84k0IlF/C4a4BuwqdM 6MEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KkpyPZF9boWkW2C3+gaN7IFNLv6yOkPRKRtBS9SK16U=; b=vGOEjj54GJG9OLTbnGKjx4gdgyF3hs5VDhur+GQNcqKX7vQ7Qvc/6lINRL3uMdZ9lx gz6rNzbhjww23b5m6Dz5zjB8cOeDBgYzbr3rR8hVSNAQypD9ZwfJVt7SGQRsTfEvzMdq EQjRvYWwWNTMuLQiMpRDK+pua/3MdG+ocS+OLwF5fiZpNCi2Rp8JfN1tfSg4Xyi5XLdb mjPtsbQFLVwvaKe3CWYjwmvMDM0m7VxbdB7H751bfb1E6jvem4i7W5XPW/X+8Jhl+v+s mle+jzMvoiTlEdWW9Z5ymCaEYxE+0lsbdwnUH/gUg4dKgdRYdmupTUrKjFU/mUXmH5E4 fFJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ZNs211dc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21si17733886pgm.563.2022.02.02.03.04.11; Wed, 02 Feb 2022 03:04:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ZNs211dc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242667AbiBAVED (ORCPT + 99 others); Tue, 1 Feb 2022 16:04:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234125AbiBAVEC (ORCPT ); Tue, 1 Feb 2022 16:04:02 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EFA4C061714; Tue, 1 Feb 2022 13:04:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=KkpyPZF9boWkW2C3+gaN7IFNLv6yOkPRKRtBS9SK16U=; b=ZNs211dcxa+SVltpBuL6iy9T/4 CUXhbiS46KQ0D5YIcD1Lz3PnMwgkP56pFexGfL1tVvPrP0irHxJOt5MEDbRH/lGgpB4hVpC/GY+7g gy/pFuMz/TOxJHN67i/pZPgwmMSfiPbrUmo7tobxqr3QZ8CGfA7sS+Y9ZI0JfBhu5l0aL+i+iHnfs 5VW6IaBsdRwsHpnN5fabQhpoHLB5nOaKSeVW/kogT7BY0iKOID7MpDdzGaAzbWOGSAGS3eVFIV/0g Cy2dvYYFqiVJyw4sWt5J0atMatSR95LG/M38OYJ1/bLw3z9nQ7iW+6kCewMpAgpIkQQJliER0oKj5 +dN7KYwA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nF0Jb-00D6Pa-6l; Tue, 01 Feb 2022 21:03:51 +0000 Date: Tue, 1 Feb 2022 21:03:51 +0000 From: Matthew Wilcox To: Shiyang Ruan Cc: linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, nvdimm@lists.linux.dev, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, djwong@kernel.org, dan.j.williams@intel.com, david@fromorbit.com, hch@infradead.org, jane.chu@oracle.com, Christoph Hellwig Subject: Re: [PATCH v10 2/9] mm: factor helpers for memory_failure_dev_pagemap Message-ID: References: <20220127124058.1172422-1-ruansy.fnst@fujitsu.com> <20220127124058.1172422-3-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220127124058.1172422-3-ruansy.fnst@fujitsu.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 27, 2022 at 08:40:51PM +0800, Shiyang Ruan wrote: > +static int mf_generic_kill_procs(unsigned long long pfn, int flags, > + struct dev_pagemap *pgmap) > +{ > + struct page *page = pfn_to_page(pfn); > + LIST_HEAD(to_kill); > + dax_entry_t cookie; > + > + /* > + * Prevent the inode from being freed while we are interrogating > + * the address_space, typically this would be handled by > + * lock_page(), but dax pages do not use the page lock. This > + * also prevents changes to the mapping of this pfn until > + * poison signaling is complete. > + */ > + cookie = dax_lock_page(page); > + if (!cookie) > + return -EBUSY; > + > + if (hwpoison_filter(page)) > + return 0; > + > + if (pgmap->type == MEMORY_DEVICE_PRIVATE) { > + /* > + * TODO: Handle HMM pages which may need coordination > + * with device-side memory. > + */ > + return -EBUSY; > + } > + > + /* > + * Use this flag as an indication that the dax page has been > + * remapped UC to prevent speculative consumption of poison. > + */ > + SetPageHWPoison(page); > + > + /* > + * Unlike System-RAM there is no possibility to swap in a > + * different physical page at a given virtual address, so all > + * userspace consumption of ZONE_DEVICE memory necessitates > + * SIGBUS (i.e. MF_MUST_KILL) > + */ > + flags |= MF_ACTION_REQUIRED | MF_MUST_KILL; > + collect_procs(page, &to_kill, true); > + > + unmap_and_kill(&to_kill, pfn, page->mapping, page->index, flags); > + dax_unlock_page(page, cookie); > + return 0; > +} There's an assumption here that fsdax only has order-0 pages. pfn_to_page() is going to return the precise page for that pfn, but then page->mapping and page->index are not valid for tail pages. I'm currently trying to folio-ise memory-failure.c, and it is not going well! There are several places where it's hard to tell what should happen.