From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 072B2C636D6 for ; Fri, 17 Feb 2023 19:49:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D6F56B0073; Fri, 17 Feb 2023 14:49:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 886976B0074; Fri, 17 Feb 2023 14:49:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74E106B0075; Fri, 17 Feb 2023 14:49:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 650F26B0073 for ; Fri, 17 Feb 2023 14:49:26 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3700514022A for ; Fri, 17 Feb 2023 19:49:26 +0000 (UTC) X-FDA: 80477823132.19.08915CE Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf27.hostedemail.com (Postfix) with ESMTP id 79B5840006 for ; Fri, 17 Feb 2023 19:49:23 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=m2Yh9gU0; spf=pass (imf27.hostedemail.com: domain of jiaqiyan@google.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=jiaqiyan@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676663363; a=rsa-sha256; cv=none; b=vm2T9YUGBilnNhYOJGb9K5nD3XibT+lxp8OEa1rVLGr2Purw9PnN1Rpc8g3K6jR0u7sUXh 7Vl1aach//RbsROOr4VqxBuuSqELAFjRNGlCPyns479mEvC03j6jvTfBkkEzZDUOwSjYyn jcGpvTw8HIIn1QekMVgBXol51+ZS564= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=m2Yh9gU0; spf=pass (imf27.hostedemail.com: domain of jiaqiyan@google.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=jiaqiyan@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676663363; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KVz84+TVSqexjLhmsvwx92sPvNu9LAAS+VbYI8laosM=; b=QTCA7x4Rd/tUdLN5ANDM0YmGYLWrxS3QCCS0TZ2loHQVEj+yPcsrEJCu9CADF84XkO6EV4 hi4HvNsdC7LVke61jr4XKe8a0ef4XuBMBXb2IiUlgJ6pEXVN1BItGrW5rNsZVjtpE1AB02 9KyXaOW7eSJohPSzBirWOkhGRpC7b8g= Received: by mail-pj1-f41.google.com with SMTP id ml23-20020a17090b361700b00234463de251so2458012pjb.3 for ; Fri, 17 Feb 2023 11:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KVz84+TVSqexjLhmsvwx92sPvNu9LAAS+VbYI8laosM=; b=m2Yh9gU0BENvT/jaYCOjPwGbQz5ol/u2s0/QNXXPkm9aeyJMYAkiK1asB0oCF0YItL LUrIx6GbmqTJy4kBigAQxejM6HRNfIGb1Xj08ABr1CgJBxZTBSI5uCVC3Yf/nFAomxEm mVeu99QvtzRmRzb5Q6APU2oNlmzsouL0cGkfuzvyg2nYcQ90k45oPPfwsHd/NFZrZjc1 DAiMvJ+XnmbARY0AUju2nYhT64PUA+k07I4lEAuJ0Bj0jbGVR3YKsIKRYTstUljQRsQG i0FvG6OoXawidX+xQiZEkqF6tGNuuj9AdsPY1zgRyjeuf8PU4tLHoj+i2VPTsucTZDAJ ySQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KVz84+TVSqexjLhmsvwx92sPvNu9LAAS+VbYI8laosM=; b=kp2efP+hCA7EhAekUwuBHb7JROSOJHCvZsAnVYKZaU8XrQcwUHMBLruwZlRGZ5j5PM Iazo3P5D4UOptXxRxyBOuStcZmLzUvklbj5UwM4TevlzSDwAQ/ZtQMGXpu0Iuo5e35KD lh4nwGx5CU0UB3IZxHSxgtW+xxC8gLHi0Ofuaou8mgubojtwr1Ahq0M10JEiyBAci8fL 1cocVKpNZZc0L1ugQL+7sW9zu921TDH+hN2vutQD3iWG8wUToXazsqUNPtCGu1r6LxYv /EnwT02lrdK2r6Yd+nvzvI9UyPObuOXtPbi7K5UTkxp9uROFGRwBjsipfDpQATFWr1wt fK4w== X-Gm-Message-State: AO0yUKVjbGHnvXUVlPF2XXDDsC+yItwSpLBlcwQllunCEM+6E5BhHDkz QcOU9x66mr0/fvUovzBQmLIIklZtVHd3vJkFuYAcFQ== X-Google-Smtp-Source: AK7set+hj0IF9DqoTbIOtuDNWT2zkEoLND0OdV2yq5ge+/NrFLbqqOPYegiHRd/0vz1+qb21ihkxawKTJ7Bnv/1qndY= X-Received: by 2002:a17:90b:264e:b0:236:8e3e:1db2 with SMTP id pa14-20020a17090b264e00b002368e3e1db2mr332615pjb.87.1676663362062; Fri, 17 Feb 2023 11:49:22 -0800 (PST) MIME-Version: 1.0 References: <20221205234059.42971-1-jiaqiyan@google.com> <20221205234059.42971-2-jiaqiyan@google.com> <20230119150258.npfadnefkpny5fd3@box.shutemov.name> <20230124003349.m64heg7mnqw7snyh@box.shutemov.name> <20230202000102.mqgyquncvqe6wkno@box.shutemov.name> <20230202003034.cgtsz2mixfcige3p@box.shutemov.name> In-Reply-To: From: Jiaqi Yan Date: Fri, 17 Feb 2023 11:49:10 -0800 Message-ID: Subject: Re: [PATCH v9 1/2] mm/khugepaged: recover from poisoned anonymous memory To: kirill@shutemov.name Cc: elver@google.com, Alexander Potapenko , dvyukov@google.com, kirill.shutemov@linux.intel.com, shy828301@gmail.com, tongtiangen@huawei.com, tony.luck@intel.com, akpm@linux-foundation.org, wangkefeng.wang@huawei.com, naoya.horiguchi@nec.com, linmiaohe@huawei.com, linux-mm@kvack.org, osalvador@suse.de Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Queue-Id: 79B5840006 X-Rspamd-Server: rspam01 X-Stat-Signature: cbbhcgm3oszpd49nbkzemhrts17w3jkk X-HE-Tag: 1676663363-128739 X-HE-Meta: U2FsdGVkX19Z+t9JOU3zQ0lr9OT6zsKbks3PcqfM0NeFgeKZEWECtT0Vy9ywO0LnUjat72JRq5rsjQOuwmKeucSOvIu4MUIcrNCg6rtRvA0Ro1K9xKNix2KsWF2SA92wqtKvw4+UxGVUZv+vlDDYsKeBWVX+qkbe/5sZJV7kfdGB0u8wpSgDyUaPVwer1Q2w8qnN6OFl+2lkuLBk8mtU5UU/KGBxteqgfB5ae0Ld8NH6yssTptRc8UGU6K3jfg0S+cxuet7VuaslYx6gHpNQVGkC8rFAqJAMwPvsWA3TqvUjAKDQd5+0b4DRqEDC0ORMaD8bVIuavVpKPcqPH2XYxqZpuCXLqA9avH1HozCNFhIaZYS15/bzw8z1jsyKwRW0E//a2GcxpPBZQ7D5nYrzWP1fE7CPSowxeLbSOzs/LtCTI9eo2gl7DD+L0kOFYoRVWykneH1jZqVjfb3kB71r0e0dYsnX4i6VIvxD98wMeCJVWfFC3/izpkKGjxFvM+L3ykeZW4ph9PLXhA9dCC1AzbmXHyF8+bVJWcGw4LPiW4iGJ/KhQBt5+bSgMQeJgzVqBSuMg5hGiQa1HGQC9KaWHmPbObO2yWOGbtgV8R4Q6ADooS0un4p+VvVe+VBknioi+OvWncmQzthPm7t6/95smLNffY/CClEKBRVLh1cgqsuW9IqFXyuZRZs7CKMr+fSuCog/6Ikqf5IonP3dBKXv3yPJ/lqc/Bxu/1eCtAbU57rDSRWcSBXKzXdvzmREZMlZYBC3VamfKMJ3qZxk861NU/g5Cql49b8zshtkoYISs6D//WyTJ51L/bKMyfs8hGm5zuBVk/Iw6GjoXF5ojBbsr5JyUNlsmJF/NW6IURY8YyH8l9sDMYy/YLwDLIGthTbp52UTfyi9Ie3Y3rjGby4kKNB6ed3iP/VwLcohW6H7zN7bkVPNM6bTsj/hz9pY0aTiMrS0nFpaZdRhCLCGYxT qr/tW3ft ZhLVXr0VE8LNGAbGiQgHztMuDPbwWBPCQD8z+5PHPEcE16tr31pxiUoVUjXvLPliPpjBMWdUwQ9amJc2k9tHEbTnFLC9KLXl42cMIxTrs5oaRZ6g0oEomsYhDheKPTuG3JxlrbnNKROEGe2TBTF8KcpbGOPv66SgeF7MLpZ7o1xUzXJ2CDpt8RX+n1zLh2F/dTgzpyDWxnil03r8ephLP+I4MXWbgHS0YWFnyC8Ejo62CldcMhNoPQ4lMo8sxqieq5OkfmqNwcUWqn+4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Kirill, Given the discussion, are you ok with `copy_mc_page` introduced in this patch? If so I am going to send out v10 that has a major refactor on __collapse_huge_page_copy. Thanks, Jiaqi On Wed, Feb 8, 2023 at 3:00 PM Jiaqi Yan wrote: > > On Wed, Feb 8, 2023 at 3:45 AM Alexander Potapenko wrote: > > > > On Tue, Feb 7, 2023 at 7:20 PM Jiaqi Yan wrote: > > > > > > Pinging KMSAN experts, for the general guidance of > > > kmsan_copy_page_meta vs kmsan_unpoison_memory > > > > Oh, sorry, I've missed the previous email. > > NP, thanks for jumping in :) > > > > > copy_mc_user_highpage() is expected to copy data from the user page, > > for which no metadata is ever allocated. > > Therefore we just initialize the destination shadow with zeros instead > > of copying anything. > > > > kmsan_copy_page_meta() is used when the metadata is copied between two > > kernel pages, therefore it handles the cases when page->kmsan_shadow > > is NULL for the source and destination pages. > > > > It might be a good idea to use kmsan_copy_page_meta() in both cases, > > but to do that I want to better understand what happens when > > kmap_local_page(from) is called in copy_mc_user_highpage(). > > Where does the corresponding struct page come from? > > Kirill can correct me, but I think khugepaged always copies user pages > because it is trying to convert raw pages to THP for better userspace > application performance. Therefore khugepaged should only need > copy_mc_user_highpage(), for both file-backed and anonymous memory > pages. > > However, copy_mc_user_highpage() needs both vaddr and vma, so it is a > little bit hard to use it in collapse_file (i.e. in the file-backed > case): > 1. vma is not carried over to collapse_file from khugepaged_scan_mm_slot > 2. collapse_file is not directly iterating with vaddrs of pages to be copied > > (Although both vaddr and vma are unused auguments in > copy_mc_user_highpage, I think for cleanness, the caller e.g. > khugepaged should feed valid values). > > So my patchset uses copy_mc_page(and kmsan_copy_page_meta) for both > file-backed and anon memory pages. I guess as long as > kmsan_copy_page_meta doesn't do anything unexpected for user pages (at > least from my reading), we are good?