Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2025434pxj; Sat, 5 Jun 2021 10:08:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmJ9C5tyR0U9+NoG5p+BNcGR5PchSZuUjSECIr6CpEL4OCokoYZ/gICI6/OoTFlcwufp/D X-Received: by 2002:aa7:dbc3:: with SMTP id v3mr7226207edt.63.1622912925026; Sat, 05 Jun 2021 10:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622912925; cv=none; d=google.com; s=arc-20160816; b=JuQpwTJUTQJUTZtV2YRPmiA0pWA/yOuHUCxEptqUq+enpQZg3aSEIS0vTTjiSRm9f7 n6cJQu6a59WS7AzCGz/3dHfp+ktnhzdRSBTzyk0/6DT8zPCKdqojaOQOcZoN91IyFPwj f2CHsklTxmz0D13IzWQoaBgIJcaYoAzFqBQe2xkBl9cUXXkCBC7Ls1zI4ZNMNyttdSt4 QbbOGuNqxE9IL4C6yhnukjOirhNFoGSXoLZh/2IypzCLpsr22Ukk+hlJmveEk7NP07wE qMl4PGe7SKxwiE7E3h4cw/lDA28exNBIRbOqe+JcbCxSS/lrA5/Q4vjwUPIUZOXNej+E ebwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Cw6UERDphoUq19AUHiWpqLCyLFe19+bWoVwgQAYZVeI=; b=ZdF6e223nEFcUnKzd8MupRKG9EQizjyrzusvBsVrRy5kGF/JjHOMMBJMQq5YpZCDfp mhOOaNZDmEXh+NNcZkIFh1ErkduPpMfEz4l4SvrtID0/s9I2E+XiNGMfL+ZTTifqulIf 1eoRnsOOhd60Wt7K9iEzZIJ7i9w2yaxtUvDslXoc1iEpStGhN+OGrQX7irEm6oOfcLTw FzLociudY8kC2qqbUMq6JiodnWQf+j8dPUVZQ353UEL6tquwE/1LG/7OrlEUqosz/GfV psNblIijikZllqlLqqCgkfJYmyTo0zVJQF1GJHT1UG2rUXU0fJQ0T1x3p4x+1YNgIKpt Dh5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x4De8Ow1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c13si7718639ejm.484.2021.06.05.10.08.22; Sat, 05 Jun 2021 10:08:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x4De8Ow1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbhFERJI (ORCPT + 99 others); Sat, 5 Jun 2021 13:09:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:33734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbhFERJH (ORCPT ); Sat, 5 Jun 2021 13:09:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE46361416; Sat, 5 Jun 2021 17:07:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622912839; bh=8K9ZUN1X6q7QYKaoMkC5sSzJVB3RkIZbgRR8IQ4iHzQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=x4De8Ow1WFCPQahQj1Mh7hSTuUB1qDxOFpxa6yTPbIBjo526qD9iDpkpZCc18/p15 9TCgLoDTxbyQ5Goy7XmQZUK7TuuMFRx2kwWemNdhx13i0OD4Gzjnd9WVyG50J4098d 1Psbz8yOqqi+f2/r1tnfkXREw6ulgxLXGwx5/T6g= Date: Sat, 5 Jun 2021 19:07:15 +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 Subject: Re: [RFC PATCH V2] zram:calculate available memory when zram is used Message-ID: References: <1622910240-4621-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: <1622910240-4621-1-git-send-email-yongw.pur@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Also are you sure you are allowed to add a new proc file entry without breaking existing tools? thanks, greg k-h