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 EAD8BE77197 for ; Tue, 7 Jan 2025 16:49:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8C07C6B00AD; Tue, 7 Jan 2025 11:49:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8488F6B00AE; Tue, 7 Jan 2025 11:49:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E96A6B00B0; Tue, 7 Jan 2025 11:49:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4D0606B00AD for ; Tue, 7 Jan 2025 11:49:52 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C4FF180B18 for ; Tue, 7 Jan 2025 16:49:51 +0000 (UTC) X-FDA: 82981242582.11.E352F5F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id 0B0E24001A for ; Tue, 7 Jan 2025 16:49:49 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=iKFKmqTl; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736268590; 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=0Mub7zt1Q1a3AznJ4qjZnlvbkFbL0QLLznkWW1MxLFg=; b=x00EPKdUZlD3hp+SCta04pTsm2uejkBq0vR69VHBqtkVa4g9jqJ8g81KvMXPVL0mhJYEVt 66hJ6m7QBMpqFDMoRTwSJ0/aWZDqPUwkCjET6OUWyWA3eg+he/i4wSEZK5u/jOB1qtvoXD I0hAtpt1loqgMVy6NyXGke/OvOIb+P0= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=iKFKmqTl; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736268590; a=rsa-sha256; cv=none; b=udptWZ33OPastVhX0aV47UeH0AkUOezhagkTs/zdLc5Ag4vVe3Gj47db610//hZOMWRkgM KFuf8xXB3tPZv3sp8qd0DDp1oX8/adIVry762rFyU5NrYUrb9pHYnQJbEDVdY/8xkjikVD cjQhviEi3QM/tGMv24RAZqKkKJzpnwE= 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=0Mub7zt1Q1a3AznJ4qjZnlvbkFbL0QLLznkWW1MxLFg=; b=iKFKmqTlwxniOLnDWDBgiHeKVB qn0llsgKMR2V/Xt0ObUs3uhp638aB6hM70ehK+0lfNR/9mksyAi8pwiApO/92/Euokle0PMMDKHpj f1uAN0AR4PZqPKV80q05L4BMfjOoxrsiedaoI1aWq/O0YCm4yPVfOgN1/lPjikafJ3Ft8R2dgzcFa WSrUn9uPdWPgXnaIMOx8SDXSb6NVqU93ltL/ru84t925583klrUyUgpBOzTfe2RKjfuOpqKd7PNwd 1YMZ+TWQsOK1wbbPXFYABZk6mvkr5GC7UEkioa4Jw+lT4jec8zjzbjbzLVpdDxUbydFiz3jQtDgn0 PAjiiUgg==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tVCm1-00000008NJF-2vP5; Tue, 07 Jan 2025 16:49:45 +0000 Date: Tue, 7 Jan 2025 16:49:45 +0000 From: Matthew Wilcox To: David Hildenbrand Cc: "linux-mm@kvack.org" , "lsf-pc@lists.linux-foundation.org" Subject: Re: [LSF/MM/BPF TOPIC] Non-lru page migration in a memdesc world Message-ID: References: <2612ac8a-d0a9-452b-a53d-75ffc6166224@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2612ac8a-d0a9-452b-a53d-75ffc6166224@redhat.com> X-Rspamd-Queue-Id: 0B0E24001A X-Rspamd-Server: rspam12 X-Stat-Signature: zjrm4yr67mrawce6tqdctsda6wnf5ias X-Rspam-User: X-HE-Tag: 1736268589-646792 X-HE-Meta: U2FsdGVkX18u5MDtjdY4LJmEF8LYHoGcjTCoQrnXuLFqQWfc0Hb1HFdW3pboUZP8rD/kHSwBKpxh44S/AWL/6Vhwo6QuM3CypvulzJ3KBIO/QmIxAtzYpdR3f0HGvFinOJUVyFPg5b98TsJcWdF+Itkygo3phLHlsNHAi0Mb84gj1ShbUozAH59vRa/IHnDarohiQpRv75k94akQEPgrAvh/dT89duPMzK4Tw5xwAA4BYlPFqtZHnIFr0gD2oMYdc1YSyvIiqUL9ikH4j2TK72X0pEpR90lnOky5R4MqSkb+Xa5KCpklv/YQsAk39ZyAWl1TTI4y4RTn20Le2ulzFfoF2WySe+7z99ETPSdhfBOfVhsMTmkoR+BSVCgRjZx3g8KwtBEngcQzPEvAJ/9aSZzbazpOM//e8Awm1qogjzx3qOTyBGYI5JgH/hxRwCLYown40vP4kXdrSkk0nzmAi9orNLK09LeZsvHv2XLe0drThvdJ2RNd3M8ATPJgrwGMDQhLkgzLCTvLN7GmteTBfKxQc7sGZVkzGnxYsXFnfq7Lhhh2xQYnoMXgHxnHrlUlmyEP4aG2xZD7NsHYGFajDBV8/hiR4oG4vvWbTyEqoR2epQN25K97rnxyDrT10/PveE9imyHapDBxexorYm4hGlQUigCcS05GNLX7f9LZu65KGLii7gZ+P5s6rZTlch32wd5uuIZBc3WWjBAsO6clvxSln6TQciCYXyW4djbLVhw2xJ62+jVzHPHdiIxjN/kYbxdUjrl4yQwzbRW5R4DBK6Jeb++c4HxV/rHV+qXyglo0Ct1tzzXNzwshPSy2Sw/yKxdV8Jqu2nCZuZjPX8bd1mjWjJRjwsy9dWFqfGdYS+1UZQMI9O/H1XBHwDKEoRvN2UPT+h/qnqiSJUhyWZ+MdIJ1QqURJ3yy6H9mU0TvzM1zp1mL6hVM65qQl4eHuW4MFF5zrL4GCs3eqZtp/yx 2Jj7+1sg Bd70iiLaEhB/IQD+OXfB6j5i+5aCvo3amCcff0bKRWZIa9ykI9jEqmoD5tZzR1HtD7YQqHHMxr14G09O5LH+LZHpQylX2XjP8zxS0r0TyA50dfkZLw4kdKMlfTjMbgKofyvSZ0Q6VCOm5K+eZjmWERBd6uaGmrirw9DkCkqUQAfPSzCOA0+VAu91oBwcyoXGSUfv4p8sULlWeh+SWFtePqLp4omfqfnFLISnvGyJpvnJbH354Z8N9hfT1fOX8oNkgxkdFFwxSJW+HS5E= 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 Tue, Jan 07, 2025 at 05:11:02PM +0100, David Hildenbrand wrote: > one item on my todo list is making PageOffline pages to stop using "struct > page" members except page->type and 1/2 flags, to prepare them for the > memdesc future, to avoid unnecessary atomics, and to resolve some (so-far) > theoretical issues with temporary speculative references. Well, thank goodness someone's working on this! Because I'm stumped. > For that, we use the "non-lru page migration" framework and in that process > we make use of ... way to many members of "struct page"/"struct folio" and > rely on the refcount not being 0. For example, we certainly don't want to > allocate memdescs for PageOffline pages just so some of them can be > migrated. I mean, let's start with how we migrate pages. int migrate_pages(struct list_head *from, new_folio_t get_new_folio, free_folio_t put_new_folio, unsigned long private, enum migrate_mode mode, int reason, unsigned int *ret_succeeded) ... list_for_each_entry_safe(folio, folio2, from, lru) { We identify every folio to be migrated and put them on a list. But once non-folio things need to be migrated, this code is wrong. We could rename this to migrate_folios() and have a different function for migrating non-folio memory. But now the compaction code starts to look distressingly complex [1]. So we need a way to pass in a list/array of memory to be migrated that doesn't involve a list_head and magically trying to deduce what the memory is. I'm actually wondering about a bitmap. Generally when we migrate memory it's to create physical contiguity so perhaps passing in a base_pfn and a bitmap that contains, say, PMD_ORDER bits; then it's the job of the migration code to figure out what to do for each pfn indicated by base_pfn and the set bits in the bitmap? Although now I write this down, I guess NUMA migration doesn't behave that way. So perhaps compaction-migration and numa-migration end up using different interfaces? I think NUMA migration always migrates folios, so it can keep using get_new_folio() and put_new_folio() while the compaction-migration might need a different pair of callbacks to allocate/free memory of many different memdesc types. [1] OK, it is already distressingly complex. But we're making it even more complex.