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 95CE7C64EC7 for ; Tue, 28 Feb 2023 13:40:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBF516B0071; Tue, 28 Feb 2023 08:40:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B70176B0072; Tue, 28 Feb 2023 08:40:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A10926B0073; Tue, 28 Feb 2023 08:40:24 -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 908F06B0071 for ; Tue, 28 Feb 2023 08:40:24 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 56C8A1602CC for ; Tue, 28 Feb 2023 13:40:24 +0000 (UTC) X-FDA: 80516809968.03.467D7B2 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by imf06.hostedemail.com (Postfix) with ESMTP id 8F38218001F for ; Tue, 28 Feb 2023 13:40:20 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm3 header.b=tPN6cDUk; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=JlvWgLxO; spf=pass (imf06.hostedemail.com: domain of kirill@shutemov.name designates 64.147.123.21 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677591620; 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=g+w8TbTisg3ft5+QlwBqgxHLeaBC9VWkLK66+hvgp68=; b=5U436zEDWq9MN7IbV3UZy5SJvdfiqk4T866TywCcrtAgDv69VvKmifpDQvQFY7de+l6BmN Oy6tggd0ucmBRdAzBEGgvaWY1Axw8hiF5Oj/Ue9PWyaePvVUUATZPkQpKG3jRmw+41obn2 5+1+Sihx5FHwdWtATlJA5ns40OltE6I= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm3 header.b=tPN6cDUk; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=JlvWgLxO; spf=pass (imf06.hostedemail.com: domain of kirill@shutemov.name designates 64.147.123.21 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677591620; a=rsa-sha256; cv=none; b=KgrACmTZW3dRlaDs/3aUQ28BpjRV2Pt7bI0+M7i00/FfGQUtCh4/Ikg5nmK52nsMHGlrOY AdVYwBkx6ZCCnI6H4Nt2xYPH8voyQ+c+/+gymyNUKERukOOZpjan9FFnIGhL9pRCo3+11p CryyJXjZ2vXZW2aw0EX7Hf4ftJyMkms= Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id BB92C320098B; Tue, 28 Feb 2023 08:40:14 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 28 Feb 2023 08:40:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1677591614; x=1677678014; bh=g+ w8TbTisg3ft5+QlwBqgxHLeaBC9VWkLK66+hvgp68=; b=tPN6cDUkEYLpeOFngb 2lmin6x7DUau89kKZ3O0XUcgnW8SR8P8/Rsn/EvB9efAwBDa5Rz1sz+kagbK6tbV pGprtZsSm2i46b+2KXyjChuaqci9EUEB1bhF5UhJZPqmUX4j+VhX7FLMIoKP97vv gQhrunh1SxqNVxKnuYJOBD4tvG6jI72URu6/KLr8vt9bIBGux4N0G06UWMqKLLoV PGtUW+ZbgL/GAmcivgzDx1oilbmpdgeWFAFih2VThYn2yHHvzIu3IcKuEf3EN8r8 nPLTaktbMUj+YyX+jUrFJRT1C/pAT4PkI2xHdB8zaq+Ug8mhwKBAWwVsUTV84w9n Qvuw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1677591614; x=1677678014; bh=g+w8TbTisg3ft5+QlwBqgxHLeaBC 9VWkLK66+hvgp68=; b=JlvWgLxOG8RqfUxK5rC+mD/6BtZbmmcawysgv1wMDlgy qpI7BGlsWml5z+1cx1NCozp808e0yKXwPNFqI4dG+JGBNkv5A6HBkcdaFRmRkku5 apfCTsczyVJm2HEPdR3Ou1ZqqLKmdFl/DgO/J2CPVFILu0qEJoz2g1YxA6lVHtUZ vImBBUva8w94qIWaBRvh0z3qfyKiWxaoL5bmtBT314qmW+b3pXBxXDg1nxlh+SK9 8RGr0V+VYQ2yz0YGj/PuMLBctyoI5SSBR7enf97bzv/1fWpUEwa5v83MOhpDISvH PGCFcutSorWXnf48yeoGSRyZdcfXRESf7vufOOAeBQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudelvddgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdttddttddtvdenucfhrhhomhepkhhirhhi lhhlsehshhhuthgvmhhovhdrnhgrmhgvnecuggftrfgrthhtvghrnhepheelveevjeduje ekveeuveetveffhfekjefgheelteehhfeujedvheeijefghffhnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepkhhirhhilhhlsehshhhuthgvmh hovhdrnhgrmhgv X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 28 Feb 2023 08:40:12 -0500 (EST) Received: by box.shutemov.name (Postfix, from userid 1000) id 44B86104214; Tue, 28 Feb 2023 16:40:09 +0300 (+03) Date: Tue, 28 Feb 2023 16:40:09 +0300 From: kirill@shutemov.name To: Jiaqi Yan Cc: Alexander Potapenko , elver@google.com, 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 Subject: Re: [PATCH v9 1/2] mm/khugepaged: recover from poisoned anonymous memory Message-ID: <20230228134009.5h5qhpopkhpp23bt@box.shutemov.name> References: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8F38218001F X-Rspam-User: X-Stat-Signature: 81zr9jie5kf3ka1fgudbiki4eqtzpjkp X-HE-Tag: 1677591620-904797 X-HE-Meta: U2FsdGVkX1/5v9MxF0WGnDunr/47dZeRVN0DFqhnyvMwZKMWLxLoREZffyn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lKOdEBYvaqq4i8CzELQO4FHdvKQQAdyRSuKmlM51wzevXGX6kfXQ54W8yRu8AytxnxhdPOPFrXmuz4iBlSCcd4GtE9TzxO5b0DMbRYpuoolMfhbX3kJnyppPe0aJ77OvUxWCdK/YtSfY5TDAOhmoWRmsTDGPwahAcmFeP+x1YWN5fMn5Uj1id4CjUWfJLQA== 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: On Wed, Feb 08, 2023 at 03:00:59PM -0800, 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). It is not unused for !copy_mc_to_kernel case (basically everything but x86 and power). And it is used to flush caches. The fact that you don't have it in your implementation *may* indicate a problem. > 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? > -- Kiryl Shutsemau / Kirill A. Shutemov