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 49425C4332F for ; Wed, 23 Nov 2022 03:50:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CAA316B0074; Tue, 22 Nov 2022 22:50:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C320F6B0075; Tue, 22 Nov 2022 22:50:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD3FF6B0078; Tue, 22 Nov 2022 22:50:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 998CC6B0074 for ; Tue, 22 Nov 2022 22:50:57 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6B4091C69AE for ; Wed, 23 Nov 2022 03:50:57 +0000 (UTC) X-FDA: 80163330954.18.C4661F2 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf01.hostedemail.com (Postfix) with ESMTP id 3C8904000E for ; Wed, 23 Nov 2022 03:50:55 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id p12so15543968plq.4 for ; Tue, 22 Nov 2022 19:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ZgI153kJkkt5PmpyORDszV5rqTG/6f9C6u8V1Iy/cuM=; b=a/ujDkNKxsotcLMKHCgcaGcaPXRcjEPlWxyuFltIs/bs65prAVwO6g/P6xYrdZgf8t 14CpJHEdtLWiJr1mxrUI8kVFYEVNcj/gvoyzYDPGXmXOOZXQ0gM8Au93mPqorjKbfP3I 5Or0379Nq4RltYk/Diy7Zeh2+GkdD8oPHeOLU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZgI153kJkkt5PmpyORDszV5rqTG/6f9C6u8V1Iy/cuM=; b=ZwHGIszs6q8+pRxPaKCDzZ7BUEjocNEac2kZH5GIGzExjkHEBx2CfdArq6DXc92Ln3 0nLf8PoWdh+mI5NtcU4Ve8992KZxSmx/ySLnmDSoB/zYeuXqNt0CL+a9jTSx/y9mZIVS knhctT/qZCqC+RlUG60dIMXtzvFRwLSEs5gRc4pd7QeG48VXnQDu4RPaSJpNj9feQvbp Y5oeu2KvkQ2u/k8HrpD8+ZWJ3z22eq4U9nE/ixMoZawzIGfhWZ7n9+3BVh/T2vc6cH/Y ZtD1w+Zk7z40Csya32hx1Jzd0G4t4tjaSFIUjf8+pTX2RNEQXMT1U2LbtpZV9W/knN9F LgxA== X-Gm-Message-State: ANoB5pkH/mzLKPbKAh/HB/PVI0bT0PzJHvsR6tDUgPwahryRIFkSQbmN AJxuYz84RlO+PDCGExYfmnYYAA== X-Google-Smtp-Source: AA0mqf76YsveXXGdWDr/BwQhfOXhvB5dGKgAhOu9zf8EZagpXIasJ4xZKlIK4A/CP8/d/KiW7hiwbQ== X-Received: by 2002:a17:903:278b:b0:188:4bac:cc97 with SMTP id jw11-20020a170903278b00b001884baccc97mr7007653plb.159.1669175454003; Tue, 22 Nov 2022 19:50:54 -0800 (PST) Received: from google.com ([240f:75:7537:3187:b570:e8d2:6522:6054]) by smtp.gmail.com with ESMTPSA id a28-20020aa795bc000000b0056beae3dee2sm11811989pfk.145.2022.11.22.19.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 19:50:53 -0800 (PST) Date: Wed, 23 Nov 2022 12:50:47 +0900 From: Sergey Senozhatsky To: Johannes Weiner Cc: Sergey Senozhatsky , Nhat Pham , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, minchan@kernel.org, ngupta@vflare.org, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com Subject: Re: [PATCH v6 4/6] zsmalloc: Add a LRU to zs_pool to keep track of zspages in LRU order Message-ID: References: <20221119001536.2086599-1-nphamcs@gmail.com> <20221119001536.2086599-5-nphamcs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="a/ujDkNK"; spf=pass (imf01.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.180 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669175455; a=rsa-sha256; cv=none; b=ykbuKhmEZwHnbwv8mRJc5e7yWtOCJv/QtqAAHJtaVW+9XI92LjgZgq1Yrcs6oskf9jdVLr V21JJ+cegl/o6Wm0ttK0S8PfkSwcTx5A+vbS8tC/iyve0RwR8xa0QibGgvweVngV7pVpqw ZGc/BvRdFp/P44bcjnoDfI7qFedP/9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669175455; 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=ZgI153kJkkt5PmpyORDszV5rqTG/6f9C6u8V1Iy/cuM=; b=WBIkYIFjDcwg0hgC9bZ3CR/wDdvxLTp/bR7M34qhT5hqA+tjpzWR8A+fYuy9f4yBi/aY27 gkfDOUa7mjtG2BPBwg6QOfW8lEWmG7zGkSf1ZR4s1YhqdYqN+V9PFOKZ5o6ZM83sdm3FRH fOWy/oPh7W9VU1z4wS8XMXIsLB4hJO4= X-Rspamd-Queue-Id: 3C8904000E X-Rspam-User: Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="a/ujDkNK"; spf=pass (imf01.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.180 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam06 X-Stat-Signature: 4cms115hxujco9hcwf9xrun7ruh93i9f X-HE-Tag: 1669175455-574034 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 (22/11/22 12:42), Johannes Weiner wrote: > On Tue, Nov 22, 2022 at 10:52:58AM +0900, Sergey Senozhatsky wrote: > > On (22/11/18 16:15), Nhat Pham wrote: > > [..] > > > @@ -1249,6 +1267,15 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, > > > obj_to_location(obj, &page, &obj_idx); > > > zspage = get_zspage(page); > > > > > > +#ifdef CONFIG_ZPOOL > > > + /* Move the zspage to front of pool's LRU */ > > > + if (mm == ZS_MM_WO) { > > > + if (!list_empty(&zspage->lru)) > > > + list_del(&zspage->lru); > > > + list_add(&zspage->lru, &pool->lru); > > > + } > > > +#endif > > > > Do we consider pages that were mapped for MM_RO/MM_RW as cold? > > I wonder why, we use them, so technically they are not exactly > > "least recently used". > > This is a swap LRU. Per definition there are no ongoing accesses to > the memory while the page is swapped out that would make it "hot". Hmm. Not arguing, just trying to understand some things. There are no accesses to swapped out pages yes, but zspage holds multiple objects, which are compressed swapped out pages in this particular case. For example, zspage in class size 176 (bytes) can hold 93 objects per-zspage, that is 93 compressed swapped out pages. Consider ZS_FULL zspages which is at the tail of the LRU list. Suppose that we page-faulted 20 times and read 20 objects from that zspage, IOW zspage has been in use 20 times very recently, while writeback still considers it to be "not-used" and will evict it. So if this works for you then I'm fine. But we probably, like you suggested, can document a couple of things here - namely why WRITE access to zspage counts as "zspage is in use" but READ access to the same zspage does not count as "zspage is in use".