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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 9CCD9C47096 for ; Sun, 6 Jun 2021 10:45:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68F876140F for ; Sun, 6 Jun 2021 10:45:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229878AbhFFKrl (ORCPT ); Sun, 6 Jun 2021 06:47:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30599 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229465AbhFFKrk (ORCPT ); Sun, 6 Jun 2021 06:47:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622976350; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/HilGFSprc7YIEedvPuaQGfj7Ylt2W0rsufgmNzneQE=; b=MiQWWFKJruWhVr5kzI30l7PiiwmOkkPhmCs0yL/lAkYLx1AN9p+nRIPaDuz+1jqb/YUnrp /Wzw76mT/OHG4CJirk6fXUBLEmSs9qkOIKA29ST882n1cD971ned688dNEnEmRCRw09gJi HzrTi3VNzaek0ORGR1t2QW1DgCGkf18= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-3GwoKBLyPdWHsURLBtnnJw-1; Sun, 06 Jun 2021 06:45:49 -0400 X-MC-Unique: 3GwoKBLyPdWHsURLBtnnJw-1 Received: by mail-wr1-f72.google.com with SMTP id k25-20020a5d52590000b0290114dee5b660so6650470wrc.16 for ; Sun, 06 Jun 2021 03:45:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=/HilGFSprc7YIEedvPuaQGfj7Ylt2W0rsufgmNzneQE=; b=EVoOVpMdQEiGDfTumQdMoPRRPfZZ3NMfsOVCsXYOggWpK05Fw7DitZQYvRdVtpE3OK wuQtBfZH0OQhaiVkYNnp+dfrOisBRunvJupTzcu4ZlEYMd7dEZdkOltuooBmad1FCOwb /mDlQqPuo0SOK0likunlrMLvnAqJpVKRqSqOLO8smgQCtaua9e3eMsGcf1hvHH0M1POo vVjGudMiWYA6+qLdISGIVGa9PGLORzP53gZB6vliRQuRzjWxxXcc+AF3ujlFrOG90Jo9 6RsOCgqAmm4U9/GU9eZklXNZzQq7tBe4ZClgRl6tcVb1g7WZpxbJrP/9vA9BjEOq2Nwa xnhw== X-Gm-Message-State: AOAM533O33gIOhcX7czUs9RjSrMOhpBSYXBNavXRKsV+RAvyBTFACQUU L+qR8jhmQZ5UDWvI95M5a+GCwPKanbwYUrnQP98vtoe+E2Dns9mvS860R/wHU1+DJ5NyKHP07vb cN8siz0hlfBkiH8iDxktK3MwZifT6l6Zj0SqHXkCi0U7cTgh6OUk2cY7lMnIZ0xrutKl0 X-Received: by 2002:a1c:7508:: with SMTP id o8mr11795345wmc.70.1622976347837; Sun, 06 Jun 2021 03:45:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyT0ZOIVt4u7phjM8iGhd6Z6zCDQDV96nEVWCXs8D6/rSL4dr76fRMRcXDoMNIbSkIRNIyMTQ== X-Received: by 2002:a1c:7508:: with SMTP id o8mr11795321wmc.70.1622976347617; Sun, 06 Jun 2021 03:45:47 -0700 (PDT) Received: from [192.168.3.132] (p5b0c65e5.dip0.t-ipconnect.de. [91.12.101.229]) by smtp.gmail.com with ESMTPSA id g205sm7110144wme.6.2021.06.06.03.45.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Jun 2021 03:45:47 -0700 (PDT) Subject: Re: [RFC PATCH V2] zram:calculate available memory when zram is used To: Greg KH , yongw.pur@gmail.com Cc: minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, axboe@kernel.dk, akpm@linux-foundation.org, songmuchun@bytedance.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, linux-api@vger.kernel.org References: <1622910240-4621-1-git-send-email-yongw.pur@gmail.com> From: David Hildenbrand Organization: Red Hat Message-ID: Date: Sun, 6 Jun 2021 12:45:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On 05.06.21 19:07, Greg KH wrote: > On Sat, Jun 05, 2021 at 09:24:00AM -0700, yongw.pur@gmail.com wrote: >> From: wangyong >> >> When zram is used, available+Swap free memory is obviously >> bigger than we actually can use, because zram can compress >> memory by compression algorithm and zram compressed data >> will occupy memory too. >> >> So, we can count the compression ratio of zram in the kernel. >> The space will be saved by zram and other swap device are >> calculated as follows: >> zram[swapfree - swapfree * compress ratio] + swapdev[swapfree] >> We can evaluate the available memory of the whole system as: >> MemAvailable+zram[swapfree - swapfree * compress ratio]+swapdev[swapfree] >> >> Add an entry to the /proc/meminfo file, returns swap will save space. >> Which name is more appropriate is still under consideration. >> There are several alternative names: SwapAvailable, SwapSaved, >> SwapCompressible >> >> Signed-off-by: wangyong >> --- >> drivers/block/zram/zcomp.h | 1 + >> drivers/block/zram/zram_drv.c | 19 +++++++++ >> drivers/block/zram/zram_drv.h | 1 + >> fs/proc/meminfo.c | 1 + >> include/linux/swap.h | 10 +++++ >> mm/swapfile.c | 95 +++++++++++++++++++++++++++++++++++++++++++ >> mm/vmscan.c | 1 + >> 7 files changed, 128 insertions(+) > > You are adding a new sysfs file with no new Documentation/ABI entry. Indeed. And in the best case, the change would be accompanied with a man page update patch for the "proc" man page. > Also are you sure you are allowed to add a new proc file entry without > breaking existing tools? I think adding new entries is not a problem. Parsers have to deal with new entries popping up. For example, we introduced "ShadowCallStack:" in 2020 via 628d06a48f57 ("scs: Add page accounting for shadow call stack allocations"). -- Thanks, David / dhildenb