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 888CEC433EF for ; Thu, 7 Oct 2021 18:12:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 040B46121F for ; Thu, 7 Oct 2021 18:12:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 040B46121F 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 7476F900002; Thu, 7 Oct 2021 14:12:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F8386B0071; Thu, 7 Oct 2021 14:12:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E6B0900002; Thu, 7 Oct 2021 14:12:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0172.hostedemail.com [216.40.44.172]) by kanga.kvack.org (Postfix) with ESMTP id 4E42F6B006C for ; Thu, 7 Oct 2021 14:12:27 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F14552FD8A for ; Thu, 7 Oct 2021 18:12:26 +0000 (UTC) X-FDA: 78670436292.31.0D2F15D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 28EF3B00179C for ; Thu, 7 Oct 2021 18:12:26 +0000 (UTC) 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=Oj0OSq/SKS3+f/iWzC9fVfTe25MqHIo5NXkSVX22Nes=; b=A6sHSlr5GFIPwaFtbOFaIPv/SR UjHVCZlUoOM+xZZ20j5DWAQWyFaRKK3ORET4C9ivpWPKEgixuQzSDW6bZcscaQ22B5LFQxCh61Hhs EipMKgElJ2VlgciBSNeY9LK1I36rjaUgFz+yTepoG+HjAT55Euk1UeJr97l5azFvgdociByKmA2fM wWEoj9J4ouuwNFhEhaUPpc1/fSdBH9hSalJJle3mcrfU8O2IZYaijmYW0MTmc6ZCrZuiuB6uRYALQ vtOYu4+Jkofd4lT1XcoSo4Sk9PJcyKtf7ypZTuaV4avlY2mQSbU8Ze9Yct+6fEACMoa/en6SwzeXR hcgC9rzQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mYXrk-0027tQ-6u; Thu, 07 Oct 2021 18:11:56 +0000 Date: Thu, 7 Oct 2021 19:11:36 +0100 From: Matthew Wilcox To: Vlastimil Babka Cc: linux-mm@kvack.org, Minchan Kim , Nitin Gupta , Sergey Senozhatsky , Kent Overstreet , Johannes Weiner Subject: Re: pageless memory & zsmalloc Message-ID: References: <3a78e51a-66f2-5d4b-70ee-c2bc3969d095@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3a78e51a-66f2-5d4b-70ee-c2bc3969d095@suse.cz> Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=A6sHSlr5; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 28EF3B00179C X-Stat-Signature: obfwtkhzu4he8h57otz1scycypjmcpjk X-HE-Tag: 1633630346-529450 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 Thu, Oct 07, 2021 at 05:03:12PM +0200, Vlastimil Babka wrote: > On 10/5/21 19:51, Matthew Wilcox wrote: > > 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 > > I would be worried there is code, i.e. some pfn scanner that will see a > PageTail, lookup its compound_head() and order and use it to skip over the > rest of tail pages. Which would fail spectacularly if compound_head() > pointed somewhere else than to the same memmap array to a struct page. Yes, that's definitely a concern. What does work is the pfn scanner doing pfn |= (1 << page_order(page)) - 1; (because page_order(zspage) is 0, so this is a noop). It's something that will need to be audited before we do this.