Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp27191ybi; Thu, 30 May 2019 19:43:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwT8WTTghoHERcgKk6v5IYHUVnMyLnhwLHrRZTTArM7Dz6vxT4ibbe+jXF/B5xkibDcuzh8 X-Received: by 2002:a65:4646:: with SMTP id k6mr6574354pgr.324.1559270626835; Thu, 30 May 2019 19:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559270626; cv=none; d=google.com; s=arc-20160816; b=G01GUYgknqyLXfRliBYlVc4cOFMg+cw+6WbLIYDHRCycGC5F3FkYG4/sfY7xgiCND7 iC02lZCBeQ1m938zfEnorvmFQ5xQcg7Q9D3K1QH4tiiSfRyp+yHUeAjQ+2aPdZ67UJ7P BKT+CLWa5hiPwNsZCTCoTd023CS+JeOf0uKsiB3s5WuwxkdyKiJMtkVi4+OFZpg5sglH qFBO8YAL/hFfDicsQrpdDklrdhnX88pQ5WDqQPv2xe48ON7m3uWauWkHQtyWx6slcMb/ Wvo3mN5EDIPPGAFKqYTEqfGU0+lTBwR2t5spm1zbO6IwQ4bwHgTy93AD/vwxSeUulWfx qjlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=+OLMXcEs3qrKGR0MjG5Pet6MFnocpP6ohXP1uelfhvQ=; b=AjVZfrMdgJhsrBYZVVExXIfjzZ8EcDkU/Dlw7am+jJuq3A65r8ztfxy74s46xDoUNC BgG2/yjynPwpmoN1KmLjOVjJSfvdCsrk3rYqF+Tg9+pdsDLMNFlDarpgALsrm2lL/Aoc 1jCN2ZSekf+QVS6X3ch569KTEnk8QKH9eIxW4K9XiPxFpvZwa4I1LlRFdxGIOiEaSRTY 6lcIeXz98Q2YUOTwAX7nEOFsfWZ1Bc0hgBEyRKcOrvzSOllu9MwiOqNXRqkyqDGc19q2 2weaxl9O8+51ZiBIPvZ06CVSyCJV8F+7BsE0SyC6UWoayQNTH5AsLq5uLszVvFKvgMYJ xwYw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h34si4814900pld.187.2019.05.30.19.43.18; Thu, 30 May 2019 19:43:46 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726576AbfEaClb (ORCPT + 99 others); Thu, 30 May 2019 22:41:31 -0400 Received: from mga17.intel.com ([192.55.52.151]:37166 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726512AbfEaCla (ORCPT ); Thu, 30 May 2019 22:41:30 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2019 19:41:30 -0700 X-ExtLoop1: 1 Received: from yhuang-dev.sh.intel.com ([10.239.159.29]) by fmsmga001.fm.intel.com with ESMTP; 30 May 2019 19:41:28 -0700 From: "Huang, Ying" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Mike Kravetz , Andrea Parri , "Paul E . McKenney" , Michal Hocko , Minchan Kim , Hugh Dickins Subject: [PATCH -mm] mm, swap: Fix bad swap file entry warning Date: Fri, 31 May 2019 10:41:02 +0800 Message-Id: <20190531024102.21723-1-ying.huang@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huang Ying Mike reported the following warning messages get_swap_device: Bad swap file entry 1400000000000001 This is produced by - total_swapcache_pages() - get_swap_device() Where get_swap_device() is used to check whether the swap device is valid and prevent it from being swapoff if so. But get_swap_device() may produce warning message as above for some invalid swap devices. This is fixed via calling swp_swap_info() before get_swap_device() to filter out the swap devices that may cause warning messages. Fixes: 6a946753dbe6 ("mm/swap_state.c: simplify total_swapcache_pages() with get_swap_device()") Signed-off-by: "Huang, Ying" Cc: Mike Kravetz Cc: Andrea Parri Cc: Paul E. McKenney Cc: Michal Hocko Cc: Minchan Kim Cc: Hugh Dickins --- mm/swap_state.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index b84c58b572ca..62da25b7f2ed 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -76,8 +76,13 @@ unsigned long total_swapcache_pages(void) struct swap_info_struct *si; for (i = 0; i < MAX_SWAPFILES; i++) { + swp_entry_t entry = swp_entry(i, 1); + + /* Avoid get_swap_device() to warn for bad swap entry */ + if (!swp_swap_info(entry)) + continue; /* Prevent swapoff to free swapper_spaces */ - si = get_swap_device(swp_entry(i, 1)); + si = get_swap_device(entry); if (!si) continue; nr = nr_swapper_spaces[i]; -- 2.20.1