From patchwork Mon Jan 29 08:29:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10189403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4DB9260375 for ; Mon, 29 Jan 2018 08:29:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AE2E28861 for ; Mon, 29 Jan 2018 08:29:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D57628869; Mon, 29 Jan 2018 08:29:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6F26F28861 for ; Mon, 29 Jan 2018 08:29:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C4E789D7B; Mon, 29 Jan 2018 08:29:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0085.outbound.protection.outlook.com [104.47.32.85]) by gabe.freedesktop.org (Postfix) with ESMTPS id 61ED489D7B for ; Mon, 29 Jan 2018 08:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=r1e6tZKBl//6zdRh3/z3SXktN/jbdFghS/U6KI6ibcs=; b=SAN93NVDboy0u0zoczB5TGPi25A+CDjXoCQ89QiZv0tg4quKlBEVbAx51h/XRPlMYYmxiWYiWufqAyv8jPVnuoeeqkWZ7JY7V6hjq+69lHOaKa4kOE5BbfHdyFEC5ZreOWvEGeK9hl4fOwC7dWCCinVTeuNMUZHWi8STrOfJ+xY= Received: from DM3PR12CA0090.namprd12.prod.outlook.com (10.161.151.162) by BN6PR12MB1442.namprd12.prod.outlook.com (10.172.24.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Mon, 29 Jan 2018 08:29:49 +0000 Received: from BY2NAM03FT007.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::203) by DM3PR12CA0090.outlook.office365.com (2603:10b6:0:57::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.444.14 via Frontend Transport; Mon, 29 Jan 2018 08:29:49 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by BY2NAM03FT007.mail.protection.outlook.com (10.152.84.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.444.13 via Frontend Transport; Mon, 29 Jan 2018 08:29:48 +0000 Received: from roger-build-server.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.361.1; Mon, 29 Jan 2018 02:29:47 -0600 From: Roger He To: Subject: [PATCH] mm/swap: add function get_total_swap_pages to expose total_swap_pages Date: Mon, 29 Jan 2018 16:29:42 +0800 Message-ID: <1517214582-30880-1-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(39860400002)(396003)(39380400002)(376002)(2980300002)(428003)(189003)(199004)(16586007)(8936002)(478600001)(72206003)(53416004)(4326008)(104016004)(2906002)(26005)(50226002)(5660300001)(51416003)(68736007)(53936002)(7696005)(36756003)(106466001)(59450400001)(2351001)(47776003)(6666003)(336011)(305945005)(54906003)(316002)(97736004)(81166006)(81156014)(50466002)(48376002)(8676002)(77096007)(186003)(356003)(6916009)(86362001)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1442; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM03FT007; 1:0rapAhXlXZTL14xATB8/g5NjIfm4VhGiJQQAtp+6YhA/zpZLAam50IPqDXtCayT98dF0rablgHIS8yi4AhpPI/29HcsP0VAbbI3hssP7g3hIopZIAWlLVA7Zc93mqGWd X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 11f398fc-9b2d-4218-dbd0-08d566f275d6 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:BN6PR12MB1442; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1442; 3:iGLrlZH6TA3FAwgHBnNs0/CjHjHvTAyd6Dw9k3nKkhe+SFDXCQMJlTDjUVFVzZGaQpO/eD0wA7v/kE7E8+lEoFazmK/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6UvLqmj2inweSZT+XvZq7CsEnXJFsrALdOUR0+UcIzGsXqus/oBmE/OtAiYCxoe/dUuHgTpbNZsZyFNhqr/ntgurKEEQpPjJIOW6QKVUWCLsMi0RKbrXbrndGPdx96fjgJxa66Ci7tQEoZVMyYxedSTGHuILWTbzMxSuwVnrW0Izw95xnRCH/MmxHWxjsO1pH4TwfoQA+I8VVaqy5ScfENqGKOfqCDp67w/Y0pKhMt8YsA233UkHm8sVpgU4SJjaPeBqznnEw3esY50k2Ilqf5h02EReVovXl5ThEhigLQndG/SMqI4oDfS/5YumofkXNjpH0mbKnJqb61Kqpm1lqoiuqTU7iBSJsdhKQ+fToIJyEl0XpjjAH8nNLKo2WyNWF X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(93006095)(93003095)(10201501046)(3002001)(3231101)(944501161)(6055026)(6041288)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(6072148)(201708071742011); SRVR:BN6PR12MB1442; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1442; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1442; 4:ZaW1vhKRaD3kcrz3F5n3+ronte9xua8zvnmGVgQLIWXdyipF88Fi0Pb8xeAl5Q4lc9HfMH0hwCIRVhvrLrOJ5B3UeScMzkobQZCEGxSXoVVgvnVviJDvs5EuX+61wE3TCJwejC0UympR8SgMKm9iedy4drdYY0uH4mzo4bBrml8+efog7o6K5zlWw58l4Vl+6o3NOml7ZW0pvjeGh1SBHb5aZhrkiVHOWR+dda+og92f4HizUP1b2ODas6iDhGII/M4FDj2VbQh3LRwdUtH2A1TZ1g/oe8VE1iJqiAm6uwGMFj/gWW4l6bbKm10o8kjk X-Forefront-PRVS: 0567A15835 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q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ZQNlnQPSLGlcrk2L7q/aeh0ej7UPi4oYicUSjMHFiDyxTt/x5h0DgEWvCuYTbLvxjtrFMqVtYKx9diIwvC9aYuDKz2lSaMRAb6ZrehMDDZ9eSJG+w0I0Hg1K5HJ9VQGLLplJnc+vRVJRRKkzU SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1442; 20:6zJ75l1hGVnChhpkPKFpgKrZkssYjL7lh2d/mSxydD25ePPZQEnIDuGURaaJ7cZovmpVqvGa5waRjrGfHc/wGHH846ljR3mr9/DUkjD8MxCjYx/bSYSz8zL5lfNUIwZQi9M/4iX8kmLPV/cmAfutpFs4cs34ERHgyNh85ilHLk7SJf2S7wOdVeyVV3tM/wRCkqwh7rhKqPFk/1hY15R0vChxQ64dme09NJi5lcw5cR+WSh06wdcTL4gV747v4/gY X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2018 08:29:48.6364 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11f398fc-9b2d-4218-dbd0-08d566f275d6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1442 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mm@kvack.org, Roger He , linux-kernel@vger.kernel.org, Christian.Koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP ttm module needs it to determine its internal parameter setting. 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 */