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 2AE71C4828D for ; Mon, 5 Feb 2024 09:45:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 968406B007D; Mon, 5 Feb 2024 04:45:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EFA36B007E; Mon, 5 Feb 2024 04:45:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 768E26B0080; Mon, 5 Feb 2024 04:45:11 -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 63C7C6B007D for ; Mon, 5 Feb 2024 04:45:11 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 258F7160A1C for ; Mon, 5 Feb 2024 09:45:11 +0000 (UTC) X-FDA: 81757266822.02.11240C9 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf05.hostedemail.com (Postfix) with ESMTP id C8464100010 for ; Mon, 5 Feb 2024 09:45:08 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="F4RF/AGr"; dkim=pass header.d=suse.com header.s=susede1 header.b="F4RF/AGr"; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf05.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.130 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707126309; a=rsa-sha256; cv=none; b=fHot6rJaW6v7QEVtsql/83UfBcOr9rKa+cf9QA0RhYglnNE0+rTXf9P8CED1Cyr2UYumW/ bfw3sbBVImeff5KvAGAH1A9qnItYFgEibp0Vk636hdhRUC0jbqTv8LAde8q7bRU3OhzPHd 3MaNBUMDp64Xxdg32ETJ9NZvGvjEXmA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b="F4RF/AGr"; dkim=pass header.d=suse.com header.s=susede1 header.b="F4RF/AGr"; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf05.hostedemail.com: domain of mhocko@suse.com designates 195.135.223.130 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707126309; 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=IFUS2eDQEhftuDnZIWOnU5+uJSL4llIAh8paW0Ywd3o=; b=fT4GIDE6SQRWAsl2sehP45007JcDaohdwzoCe87Ch5BJwdJKs0SWmKZa1tOPJiJwsWmtzM AzjopMi6is6jQWo82XcVZUDJPOer+AG66uICHXXt24nwKiSIaQuAoXReMkVNTjl2/cXM5t 9Sygq8z2L0v6oae4hsx4NqlvHa2IkGI= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DD2A422117; Mon, 5 Feb 2024 09:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1707126306; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IFUS2eDQEhftuDnZIWOnU5+uJSL4llIAh8paW0Ywd3o=; b=F4RF/AGrHcSLPbYB6W0Sc6LXnGhZ3hkiKNhTW5785+6Thkvh+C45vLXGw9pZYWDJi8eYMQ YCrLAjuCx1xqWKTKEPq6rsXLp0onu7t8nbpIUdc19aff4ZpKaHDshPGYANnwxm5fihhLrD MULb6f3cqsQE45HusK/TQD+ggWlv7Co= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1707126306; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IFUS2eDQEhftuDnZIWOnU5+uJSL4llIAh8paW0Ywd3o=; b=F4RF/AGrHcSLPbYB6W0Sc6LXnGhZ3hkiKNhTW5785+6Thkvh+C45vLXGw9pZYWDJi8eYMQ YCrLAjuCx1xqWKTKEPq6rsXLp0onu7t8nbpIUdc19aff4ZpKaHDshPGYANnwxm5fihhLrD MULb6f3cqsQE45HusK/TQD+ggWlv7Co= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B3BE413707; Mon, 5 Feb 2024 09:45:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Cyp0KSKuwGU+IwAAD6G6ig (envelope-from ); Mon, 05 Feb 2024 09:45:06 +0000 Date: Mon, 5 Feb 2024 10:45:02 +0100 From: Michal Hocko To: Yang Shi Cc: Lance Yang , akpm@linux-foundation.org, zokeefe@google.com, david@redhat.com, songmuchun@bytedance.com, peterx@redhat.com, minchan@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] mm/khugepaged: skip copying lazyfree pages on collapse Message-ID: References: <20240201125226.28372-1-ioworker0@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spamd-Bar: / X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C8464100010 X-Stat-Signature: 5rt9e1ohwea8edwo4sampsm76fiwo6ut X-HE-Tag: 1707126308-403806 X-HE-Meta: U2FsdGVkX1+aLvzi8N8ZQmzB3IQGpdD40+bt1SPkBP1Z+I43LM2CdAojl2l1K144OB4suVAP6/KdfqlhWeC/47K71pz38g5h2lh5MZ5a1gHg0AIhYlidCM+IjANZql/4vL01rS9Gh/JmBAiy0snCiOr+Mq/SzATm34ZtqsG8MWAXQ/JFyRL+JoZqWarFiynWJMJFHBT2NEmjg94ZZfg1NQOUyENs+XCmpuP9iooUTK7G4Ud+anhElx2pMeA9ZZRPODvnssw8uX0QMOqS18lf+VzE31IUGNs6uLrh8gKMVfdQMRnekZzxIFS1hlIA2pEyILASFCL9OunHOMohzcYywh5gn4uNYUxp08ZveCNtQXi0qtP0weM3viAIhXGkcHcC12KJan4QrdsSzT/v4xe1MaZy6IbdApWDiJU2T4NsNEVju6/Nha7bPEAZB8rmdvK28xH+yrcl+p/9S8bB+ETftgUJU6S32czl5B9EQefhfqq+uU2Ya3boB7fzA8cVxPLQYbO0UywJozy6fBwZQl7ZsM0ayssXVCQIiWmcsSErRqemkqPngO5MAxUc0YKtXkR1ga4LE+P2slcJJELUY3PcXREnENnOL4Tzoq0F8MenSvRdzPernFDbLAdbfCOh0ry7pDLwcCOy4lTPUTcgpVMkfP+Y9jCQyLCvmYfb6J8+2DP1rLbRm/IeiAd6Z4MrQUmoveHOy6dSzoleWz00oedvu+/Trc+Q465qOsmg1wGhFnFR8Mn23l2ItFuFhj4Sh8IcqsgrJOYggtYhjH5Slnz9hzL536vJAiY4T7P6lCSKNKAXZnBZ93QLemN4ZpkeyOC1uuA03BwxLWP4HMnra63XM/xDQzfJ47JptKRYZRWFdlpz4K0HWUm4BdQE8mPdHl3C3s8JFNDTnP0CDlVOjvi+25jhX8kjp4niI8zAc5nedoCo7fBq2/0ylk+WzqjcWE33FjcXtKgFPki/tszXvWy zMlqxCcR phh9SlzXwVcfUzTH8f+yc2pP7Wt0y++yr9+lWKK544GBKrBKoEpuGQMUEEFHZgSRGVN+fhBiOe85+7oXbUsouZ+BKb6KHnGiEgYkexxUB/FHjNkadS0l8vWjaR/S3VHwbqL4kZPa5sZ+mI5PEN8GVJ79wKF2iS71MxTRq2cZzYx+lVtfJChaVvRjeWuKcA3+6MAUMeqVfwGCBLrVYrfGZbGx6cw== 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: List-Subscribe: List-Unsubscribe: On Fri 02-02-24 09:42:27, Yang Shi wrote: > But if the partial range is MADV_FREE, khugepaged won't skip them. > This is what your second test case does. > > Secondly, I think it depends on the semantics of MADV_FREE, > particularly how to treat the redirtied pages. TBH I'm always confused > by the semantics. For example, the page contained "abcd", then it was > MADV_FREE'ed, then it was written again with "1234" after "abcd". So > the user should expect to see "abcd1234" or "00001234". Correct. You cannot assume the content of the first page as it could have been reclaimed at any time. > I'm supposed it should be "abcd1234" since MADV_FREE pages are still > valid and available, if I'm wrong please feel free to correct me. If > so we should always copy MADV_FREE pages in khugepaged regardless of > whether it is redirtied or not otherwise it may incur data corruption. > If we don't copy, then the follow up redirty after collapse to the > hugepage may return "00001234", right? Right. As pointed above this is a valid outcome if the page has been dropped. User has means to tell that from /proc/vmstat though. Not in a great precision but I think it would be really surprising to not see any pglazyfreed yet the content is gone. I think it would be legit to call it a bug. One could argue the bug would be in the accounting rather than the khugepaged implementation because madvised pages could be dropped at any time. But I think it makes more sense to copy the existing content. -- Michal Hocko SUSE Labs