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 15F40C433FE for ; Thu, 7 Oct 2021 15:03:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C01C561056 for ; Thu, 7 Oct 2021 15:03:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C01C561056 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 35DD46B0071; Thu, 7 Oct 2021 11:03:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E704900003; Thu, 7 Oct 2021 11:03:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18781900002; Thu, 7 Oct 2021 11:03:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0155.hostedemail.com [216.40.44.155]) by kanga.kvack.org (Postfix) with ESMTP id 080076B0071 for ; Thu, 7 Oct 2021 11:03:15 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C49D92D388 for ; Thu, 7 Oct 2021 15:03:14 +0000 (UTC) X-FDA: 78669959508.15.0737179 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf18.hostedemail.com (Postfix) with ESMTP id 093474002A67 for ; Thu, 7 Oct 2021 15:03:13 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C0DFF200D2; Thu, 7 Oct 2021 15:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1633618992; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AphIAS+3UBZG9yrjoMW2fyP1X3YLR8zd6rj0quq1NtI=; b=WXRxtMdL/rQB7tXTfVwh+NMxvebWbJE4SRessYXk+4MPnkBuBNp0p/Z095ozQv7B+Xs0qd nvmiX+yeYh+Xv/DhBDCO5cEYmSsdX1zhSuoAdH5TkfinRhsI8mmkXvYQsEWX7zS7V2nCNO SeGBLEt+5Zp8e/4jxSHs2C0Ri8HM0dU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1633618992; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AphIAS+3UBZG9yrjoMW2fyP1X3YLR8zd6rj0quq1NtI=; b=paA4pABzIIf3AAGmXINKVhnMf/Hs0rzLrYXMLdWXTfOvj/554KBaixmXNQTneKOv514Svq QuGqPnmYrznsejDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9D13B13CE5; Thu, 7 Oct 2021 15:03:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Pb6oJTAMX2EWcAAAMHmgww (envelope-from ); Thu, 07 Oct 2021 15:03:12 +0000 Message-ID: <3a78e51a-66f2-5d4b-70ee-c2bc3969d095@suse.cz> Date: Thu, 7 Oct 2021 17:03:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Content-Language: en-US To: Matthew Wilcox , linux-mm@kvack.org Cc: Minchan Kim , Nitin Gupta , Sergey Senozhatsky , Kent Overstreet , Johannes Weiner References: From: Vlastimil Babka Subject: Re: pageless memory & zsmalloc In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 093474002A67 X-Stat-Signature: qtdbfij3ddjr4f5sidrsksa3d1d97ac6 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=WXRxtMdL; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=paA4pABz; dmarc=none; spf=pass (imf18.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-HE-Tag: 1633618993-396034 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 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. > 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. >