Received: by 10.223.176.5 with SMTP id f5csp3084633wra; Mon, 29 Jan 2018 08:32:20 -0800 (PST) X-Google-Smtp-Source: AH8x224IjTjvUTisSEyHJ+vxrYj2QSZzB7eQ1hVlFpvcmTzQhMVpBZRQewwa2JUiLloQMz2AopU1 X-Received: by 10.99.55.66 with SMTP id g2mr22202659pgn.61.1517243540122; Mon, 29 Jan 2018 08:32:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517243540; cv=none; d=google.com; s=arc-20160816; b=YIw1i1gkRpUR50lrc6Y4xrRiUHMt7o9Yhghi3IF0vkitnGLuNxmu18IVuOOpoM3UwX YUXBhy1iLRjpCsYNYyadR4GdUerk92Y3hiffoQgK6P4qRvybzSdwbQtpn7WB/Bimk9gc BRl+vQ9eg33oboTStvi1BVwxGQkcjjNSitqIQBNVEximIahUFafo2KhexKrVkL/TV5mH Ht1WR5yDc9IJzLaYhbHXk18Dc/5OYJn3No43LHRsrpFDqH5nRrHLj1IW397+FAkmnnYE 5zUkefvClslRKBx71uNoj/5jB1bFFE5Ew7Oeg6HHA/wXklfN+B2XaBfaCQJfg9niJAu4 9Djg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=zKpZ+8XYR36ioX59dPU1Cz2LUu0mWBbNNxp4P9BToQ4=; b=E5D693jGnMf5q4lmMddgK86xgtAVlfXoMNCIvJn+tx29EmcqGBh+psJWXVD2SUThDA jTM1WJ16H7VGbqLgzXQihdjBN2eYUsfQS+k9ztdsClFA16pwsdZ7JZeSwR98jlM4Zu3H hV/TBhrGS8b48BqI6eh+ndDXSMoEX9T+Lew8yearBAwyw9G5598CfK1RY96+DvXB+/IE pA80y7Bw2++Ed0iMINhuDH4cibIIgLe8CgbE3fBLtG+STY1yzOOz/RM7uYRpxXAmxN5T 1hmhEcDREmkTOv4p+JWRFDTQLQNS14C4ptm34Uugvy+ALyPxoPHwAIgwL7q7p+Qx7JXZ VslQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e82si297451pfh.394.2018.01.29.08.32.05; Mon, 29 Jan 2018 08:32:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751573AbeA2QbV (ORCPT + 99 others); Mon, 29 Jan 2018 11:31:21 -0500 Received: from mx2.suse.de ([195.135.220.15]:55035 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751542AbeA2QbR (ORCPT ); Mon, 29 Jan 2018 11:31:17 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6E938AC20; Mon, 29 Jan 2018 16:31:16 +0000 (UTC) Date: Mon, 29 Jan 2018 17:31:14 +0100 From: Michal Hocko To: Roger He Cc: dri-devel@lists.freedesktop.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christian.Koenig@amd.com Subject: Re: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages Message-ID: <20180129163114.GH21609@dhcp22.suse.cz> References: <1517214582-30880-1-git-send-email-Hongbo.He@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1517214582-30880-1-git-send-email-Hongbo.He@amd.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 29-01-18 16:29:42, Roger He wrote: > ttm module needs it to determine its internal parameter setting. Could you be more specific why? > Signed-off-by: Roger He > --- > include/linux/swap.h | 6 ++++++ > mm/swapfile.c | 15 +++++++++++++++ > 2 files changed, 21 insertions(+) > > diff --git a/include/linux/swap.h b/include/linux/swap.h > index c2b8128..708d66f 100644 > --- a/include/linux/swap.h > +++ b/include/linux/swap.h > @@ -484,6 +484,7 @@ extern int try_to_free_swap(struct page *); > struct backing_dev_info; > extern int init_swap_address_space(unsigned int type, unsigned long nr_pages); > extern void exit_swap_address_space(unsigned int type); > +extern long get_total_swap_pages(void); > > #else /* CONFIG_SWAP */ > > @@ -516,6 +517,11 @@ static inline void show_swap_cache_info(void) > { > } > > +long get_total_swap_pages(void) > +{ > + return 0; > +} > + > #define free_swap_and_cache(e) ({(is_migration_entry(e) || is_device_private_entry(e));}) > #define swapcache_prepare(e) ({(is_migration_entry(e) || is_device_private_entry(e));}) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 3074b02..a0062eb 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -98,6 +98,21 @@ static atomic_t proc_poll_event = ATOMIC_INIT(0); > > atomic_t nr_rotate_swap = ATOMIC_INIT(0); > > +/* > + * expose this value for others use > + */ > +long get_total_swap_pages(void) > +{ > + long ret; > + > + spin_lock(&swap_lock); > + ret = total_swap_pages; > + spin_unlock(&swap_lock); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(get_total_swap_pages); > + > static inline unsigned char swap_count(unsigned char ent) > { > return ent & ~SWAP_HAS_CACHE; /* may include SWAP_HAS_CONT flag */ > -- > 2.7.4 -- Michal Hocko SUSE Labs