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=-5.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 936CDC48BE5 for ; Tue, 8 Jun 2021 09:29:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 46C0C61263 for ; Tue, 8 Jun 2021 09:29:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 46C0C61263 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D98EC6B006C; Tue, 8 Jun 2021 05:29:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D7AD96B006E; Tue, 8 Jun 2021 05:29:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5E7D6B0070; Tue, 8 Jun 2021 05:29:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0099.hostedemail.com [216.40.44.99]) by kanga.kvack.org (Postfix) with ESMTP id 95FCE6B006C for ; Tue, 8 Jun 2021 05:29:22 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 28EF9181AEF1D for ; Tue, 8 Jun 2021 09:29:22 +0000 (UTC) X-FDA: 78230033364.09.18F84E9 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf08.hostedemail.com (Postfix) with ESMTP id AACDF801936A for ; Tue, 8 Jun 2021 09:29:18 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 3D2EB61278; Tue, 8 Jun 2021 09:29:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623144560; bh=DFQHA9AN0Bwqi+IGT+h997v/dvvg0EVj1Zuf554QF0Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OMc2fpUYVysUoQldR/Lysq905drBSZN0I8fEucHDRKLyfJMvV2rQZfAQzc9q0TC0o +dp/oboZGUcmjPNwP9zqz0DgrqNoyrpNuHe4+AcCbggcoImZx1SwXFe3jiSc/ujFPt 3v4BkLgjwje0l21Y+dNLdfrlX3kfCwHgdr1eGym0= Date: Tue, 8 Jun 2021 11:29:18 +0200 From: Greg KH To: yongw.pur@gmail.com Cc: minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, axboe@kernel.dk, akpm@linux-foundation.org, songmuchun@bytedance.com, david@redhat.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, linux-api@vger.kernel.org, lu.zhongjun@zte.com.cn, yang.yang29@zte.com.cn, zhang.wenya1@zte.com.cn, wang.yong12@zte.com.cn Subject: Re: [RFC PATCH V3] zram:calculate available memory when zram is used Message-ID: References: <1623080354-21453-1-git-send-email-yongw.pur@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1623080354-21453-1-git-send-email-yongw.pur@gmail.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: AACDF801936A X-Stat-Signature: y9oc13qwxbsckb7utpyob5rb3gpq4k5u Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=OMc2fpUY; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf08.hostedemail.com: domain of gregkh@linuxfoundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org X-HE-Tag: 1623144558-126750 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 Mon, Jun 07, 2021 at 08:39:14AM -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] Why is this needed to be exported by userspace? Who is going to use this information and why can't they just calculate it from the exported information already? What tool requires this new information and what is it going to be used for? And why add a block driver's information to a core proc file? Shouldn't the information only be in the block driver's sysfs directory only? thanks, greg k-h