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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8129EC433F5 for ; Tue, 5 Oct 2021 17:52:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 070406115B for ; Tue, 5 Oct 2021 17:52:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 070406115B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 498B06B006C; Tue, 5 Oct 2021 13:52:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 446666B0071; Tue, 5 Oct 2021 13:52:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 335CC6B0073; Tue, 5 Oct 2021 13:52:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0162.hostedemail.com [216.40.44.162]) by kanga.kvack.org (Postfix) with ESMTP id 25A156B006C for ; Tue, 5 Oct 2021 13:52:03 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C869A2FE16 for ; Tue, 5 Oct 2021 17:52:02 +0000 (UTC) X-FDA: 78663127284.18.9BE24EB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP id 379741039EC2 for ; Tue, 5 Oct 2021 17:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=rSVS9BMwL6/4NndqqB5bZZ03zwfHcMzuBo4bkLxVrzY=; b=LGBBx88q4mJp6u1elJeh/lQXWq BxLzBTSOUJMq0p2KV+w9LWXlpXgGqxMxmFOEX4Xs6yKPxtoolSn94lMqvb9VgqRh1NmFzjFobqMUB JMJG7Vm59UStWN8ZN7DyF/CJG46YN9Ft3/Ak16qI2NOkGeBLuk9KZ0a6DR87zLaMd0RvfyQcgkiKI 6o+MbqQil6eE6b3IL+5DGGtJ6XdmTaa1MgBfqZW9OnxhZzbEAdxdcA+KvW2uI+50smLTnCIgfM5Kv c0cNgKLb7Of6WJi6ItOwvagVLSOnEYSteQXfHs2k4pU88OeIIJlwPP+N82Xs/YCGkHweVK3VY72Dn Ka0hq55w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXobE-0008ZL-K8; Tue, 05 Oct 2021 17:51:37 +0000 Date: Tue, 5 Oct 2021 18:51:32 +0100 From: Matthew Wilcox To: linux-mm@kvack.org Cc: Minchan Kim , Nitin Gupta , Sergey Senozhatsky , Kent Overstreet , Johannes Weiner Subject: pageless memory & zsmalloc Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 379741039EC2 X-Stat-Signature: 6tb6dbihwraypk9s4n76gpwyp5oahaxg Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=LGBBx88q; dmarc=none; spf=none (imf13.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1633456322-946432 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: We're trying to tidy up the mess in struct page, and as part of removing slab from struct page, zsmalloc came on my radar because it's using some of slab's fields. The eventual endgame is to get struct page down to a single word which points to the "memory descriptor" (ie the current zspage). zsmalloc, like vmalloc, allocates order-0 pages. Unlike vmalloc, zsmalloc allows compaction. Currently (from the file): * Usage of struct page fields: * page->private: points to zspage * page->freelist(index): links together all component pages of a zspage * For the huge page, this is always 0, so we use this field * to store handle. * page->units: first object offset in a subpage of zspage * * Usage of struct page flags: * PG_private: identifies the first component page * PG_owner_priv_1: identifies the huge component page This isn't quite everything. For compaction, zsmalloc also uses page->mapping (set in __SetPageMovable()), PG_lock (to sync with compaction) and page->_refcount (compaction gets a refcount on the page). Since zsmalloc is so well-contained, I propose we completely stop using struct page in it, as we intend to do for the rest of the users of struct page. That is, the _only_ element of struct page we use is compound_head and it points to struct zspage. That means every single page allocated by zsmalloc is PageTail(). Also it means that when isolate_movable_page() calls trylock_page(), it redirects to the zspage. That means struct zspage must now have page flags as its first element. Also, zspage->_refcount, and zspage->mapping must match their locations in struct page. That's something that we'll get cleaned up eventually, but for now, we're relying on offsetof() assertions. The good news is that trylock_zspage() no longer needs to walk the list of pages, calling trylock_page() on each of them. Anyway, is there a good test suite for zsmalloc()? Particularly something that would exercise its interactions with compaction / migration? I don't have any code written yet.