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 EBB54C47096 for ; Sun, 6 Jun 2021 10:45:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6921C6141E for ; Sun, 6 Jun 2021 10:45:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6921C6141E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5526D6B006C; Sun, 6 Jun 2021 06:45:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5024E6B006E; Sun, 6 Jun 2021 06:45:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 355406B0070; Sun, 6 Jun 2021 06:45:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id 03A246B006C for ; Sun, 6 Jun 2021 06:45:53 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 97D9D8419 for ; Sun, 6 Jun 2021 10:45:53 +0000 (UTC) X-FDA: 78222968586.16.83EE396 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf08.hostedemail.com (Postfix) with ESMTP id AC0D58019358 for ; Sun, 6 Jun 2021 10:45:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622976352; 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=CBNHEm+Vm1+uUIa0HRqh67QREdIeCsvUV9xAllI0dIgOOI33VGRpfa1/WG9UYGJopR1x4I auMF6TNZyV1pLXjVDqXUCVOi4+hOrnDR+HsB2QZjmrEbGR/D8DAQLG8MF/wq4KHzJzjxj/ KBDTxAtCFNv7B3tD8ZnwvIfkC0M9RjU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-XKkt5DSjPM6omQFHGh6d2Q-1; Sun, 06 Jun 2021 06:45:48 -0400 X-MC-Unique: XKkt5DSjPM6omQFHGh6d2Q-1 Received: by mail-wr1-f70.google.com with SMTP id t14-20020adfe44e0000b029011851efa802so6610684wrm.11 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=RRYoB/WeOPnOYLp7Cl93+sjqDcNrAlvdnhT9YYPqePxCidPUonoSNvcKfy5d2vmp+c 3vZcIEWZ8hnVSr0de2cLzq7nyHhopmz/O/OKHDGqnEEUnOx/MRyZKBh7S3kYPYXQY09x 3ZPTPcfvONUjVWi2ZQ1ZCQ6HQceh0pMjRsGBTwdx1yNkqjMULujR6BfmQ6sOG855ggrh JWU5uu6LNcAr/fGC1PhulsvJ/2Gqf3SlmA7Sry9eDrNLVK6Uhf69ESe8EAklNnhJN59r JK9LwxXqHH0oNm+/mYyuJ2Y252IZeVEV71urxO0M7wEDEnu2U/xY6ovPSNqwxgY7jTlD gUEg== X-Gm-Message-State: AOAM533jnReY6Gu6gVGGZFzqD8YqblvoBI4oFaXVFvU28Jn6GCgVwcmn jd4bOuH/K51NqkEJUnyy25O2i91K+y47xOL5lNfYBQ2g/iQ6zb9SGNbfTQXGTJVCP/EMI0gC8ya u+ZVvusFjAFQ= X-Received: by 2002:a1c:7508:: with SMTP id o8mr11795346wmc.70.1622976347846; 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: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CBNHEm+V; spf=none (imf08.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: q8yhm33wpe3huj9yw8dozg57p8p19yjf X-Rspamd-Queue-Id: AC0D58019358 X-Rspamd-Server: rspam06 X-HE-Tag: 1622976351-228261 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 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