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 X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05E0BC11F68 for ; Fri, 2 Jul 2021 05:47:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 80BC46141C for ; Fri, 2 Jul 2021 05:47:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80BC46141C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C2CDC6B0036; Fri, 2 Jul 2021 01:47:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB5E96B0074; Fri, 2 Jul 2021 01:47:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EC398D0001; Fri, 2 Jul 2021 01:47:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0025.hostedemail.com [216.40.44.25]) by kanga.kvack.org (Postfix) with ESMTP id 73D836B0036 for ; Fri, 2 Jul 2021 01:47:48 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 212A6183BA077 for ; Fri, 2 Jul 2021 05:47:48 +0000 (UTC) X-FDA: 78316566216.19.ECBDE02 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf22.hostedemail.com (Postfix) with ESMTP id D2DB91988 for ; Fri, 2 Jul 2021 05:47:47 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id n11so5754254pjo.1 for ; Thu, 01 Jul 2021 22:47:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2wK0sFMdIZyCO2WDDH+HS8h56bpuMmkc9e3XYE6mC5Q=; b=qnmeXfnHyTdcxzSWqkrnRdF2V//PUbXbCggyVQvBBlImgYwbIwgnUm6ym34I4xErv2 6MGrB3Tkkm6p0KjJF9w3F82WPl/xLdcPBDWEOSf7XXYL1fGDtOf7VcYxIfdYA5fCvjLk QoFE+LYblZyAosZAA8iP3SbFkuEM7PwYh/B732Bx09daQx1XWvI/TGoXKtdzjXk9Ek/6 2fYEFiur77q5gOOoOE0jypLYycPfkDk/9cWN5hANTuWWLf9Dd/4ffiDEMczborexJZD6 roCtnk7h9y2yZ0czsJi1c8Z3o3kxvc+w93aY7sai88a70paIkVMLRmeuXDBYBs8cL+xw ZVvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=2wK0sFMdIZyCO2WDDH+HS8h56bpuMmkc9e3XYE6mC5Q=; b=tYNU0aiYprerSz36xv9iBvzzmnT19hIv25M8oURDWHRyQXS+fDVmdDqx/l95r9aVdP pGn4cUYWvMx9QUPzojAgBQDhZamVvQnAf7Cqo/b9xrEEwQw8+Jy3KZhPsGNsvAU6HXzc itwlrzUDfrlR4hg1l5XI1mql25RXwqHmiGxSlyGUklEdu2CddTADdKkZBR+P1oB0ch/4 99BjcXS7J5wg1DEJGKobY0yqVZPqtSjgvtiVL+G5RuZAbUteExQwLaP0kdMUYpZXkrBi ROFQQ77z/eifSB9arwtX7/8nE0zDgXo0MMwlGVzH3syGaXlvuq/hlf+aX/OjNpR4gKNM TxSg== X-Gm-Message-State: AOAM532vZyJm6DtuWlgqIbt3srLerVhV10xCn4FgKeSar6/QosDEsnu1 VZTN7eVL00VKiz+VlCUrn6g= X-Google-Smtp-Source: ABdhPJzx2qJnS6WY4yyozM0awsnrnn4p1AUviqTkpqPguXby+p7/335O/NkQcbUVuFQqnIn4jQAvLg== X-Received: by 2002:a17:90a:7e13:: with SMTP id i19mr3237480pjl.23.1625204866789; Thu, 01 Jul 2021 22:47:46 -0700 (PDT) Received: from google.com ([2620:15c:211:201:e476:fcd4:d1bf:22a2]) by smtp.gmail.com with ESMTPSA id s31sm1915055pfg.191.2021.07.01.22.47.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jul 2021 22:47:46 -0700 (PDT) Date: Thu, 1 Jul 2021 22:47:44 -0700 From: Minchan Kim To: Zhaoyang Huang Cc: LKML , Andrew Morton , "open list:MEMORY MANAGEMENT" , mm-commits@vger.kernel.org, Sergey Senozhatsky , torvalds@linux-foundation.org, Zhaoyang Huang Subject: Re: [patch 108/192] mm: zram: amend SLAB_RECLAIM_ACCOUNT on zspage_cachep Message-ID: References: <20210630184624.9ca1937310b0dd5ce66b30e7@linux-foundation.org> <20210701015258.BrxjIzdE1%akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D2DB91988 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=qnmeXfnH; spf=pass (imf22.hostedemail.com: domain of minchankim@gmail.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=minchankim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-Stat-Signature: pptsazgxxpi7rx7kpm1ezu5hckkybasu X-HE-Tag: 1625204867-513022 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 Fri, Jul 02, 2021 at 10:45:09AM +0800, Zhaoyang Huang wrote: > On Thu, Jul 1, 2021 at 10:56 PM Minchan Kim wrote: > > > > On Wed, Jun 30, 2021 at 06:52:58PM -0700, Andrew Morton wrote: > > > From: Zhaoyang Huang > > > Subject: mm: zram: amend SLAB_RECLAIM_ACCOUNT on zspage_cachep > > > > > > Zspage_cachep is found be merged with other kmem cache during test, which > > > is not good for debug things (zs_pool->zspage_cachep present to be another > > > kmem cache in memory dumpfile). It is also neccessary to do so as > > > shrinker has been registered for zspage. > > > > > > Amending this flag can help kernel to calculate SLAB_RECLAIMBLE correctly. > > > > > > Link: https://lkml.kernel.org/r/1623137297-29685-1-git-send-email-huangzhaoyang@gmail.com > > > Signed-off-by: Zhaoyang Huang > > > Cc: Minchan Kim > > > Cc: Sergey Senozhatsky > > > Signed-off-by: Andrew Morton > > > > Sorry for the late. I don't think this is correct. > > > > It's true "struct zspage" can be freed by zsmalloc's compaction registerred > > by slab shrinker so tempted to make it SLAB_RECLAIM_ACCOUNT. However, it's > > quite limited to work only when objects in the zspage are heavily fragmented. > > Once the compaction is done, zspage are never discardable until objects are > > fragmented again. It means it could hurt other reclaimable slab page reclaiming > > since the zspage slab object pins the page. > IMHO, kmem cache's reclaiming is NOT affected by SLAB_RECLAIM_ACCOUNT > . This flag just affects kmem cache merge[1], the slab page's migrate > type[2] and the page's statistics. Actually, zspage's cache DO merged > with others even without SLAB_RECLAIM_ACCOUNT currently, which maybe > cause zspage's object will NEVER be discarded.(SLAB_MERGE_SAME > introduce confusions as people believe the cache will merge with > others when it set and vice versa) > > [1] > struct kmem_cache *find_mergeable(size_t size, size_t align, unsigned > long flags, const char *name, void (*ctor)(void *)) > ... > if ((flags & SLAB_MERGE_SAME) != (s->flags & SLAB_MERGE_SAME)) > continue; > > [2] > if (s->flags & SLAB_RECLAIM_ACCOUNT) > s->allocflags |= __GFP_RECLAIMABLE; That's the point here. With SLAB_RECLAIM_ACCOUNT, page allocator try to allocate pages from MIGRATE_RECLAIMABLE with belief those objects are easily reclaimable. Say a page has object A, B, C, D and E. A-D are easily reclaimable but E is hard. What happens is VM couldn't reclaim the page in the end due to E even though it already reclaimed A-D. And the such fragmenation could be spread out entire MIGRATE_RECLAIMABLE pageblocks over time. That's why I'd like to put zspage into MIGRATE_UNMOVALBE from the beginning since I don't think it's easily reclaimble once compaction is done.