From patchwork Mon Nov 19 00:47:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 10688083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE19013BF for ; Mon, 19 Nov 2018 00:48:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEDA7299AB for ; Mon, 19 Nov 2018 00:48:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C20FF299B2; Mon, 19 Nov 2018 00:48:20 +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=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D871299AB for ; Mon, 19 Nov 2018 00:48:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBA0E6B1794; Sun, 18 Nov 2018 19:48:18 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B42516B1795; Sun, 18 Nov 2018 19:48:18 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E42C6B1796; Sun, 18 Nov 2018 19:48:18 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) by kanga.kvack.org (Postfix) with ESMTP id 76B146B1794 for ; Sun, 18 Nov 2018 19:48:18 -0500 (EST) Received: by mail-it1-f199.google.com with SMTP id e19-v6so6403178itc.0 for ; Sun, 18 Nov 2018 16:48:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:mime-version:content-transfer-encoding; bh=6gyrhKbOCiv+zElf5LSN4Pe6YN3X6Cu7b8UNoJgG0NU=; b=K7FjxZwG043PIXnWUCrGfKs51CcYzlOp48bDD11Zr7g8uvebWpi670rg9n1d5TLgGh L9OHI30QlA+beZ2BfoVzc1jISEExSzvYw3u+89374jPbkl6KqtQmCnRRl/GkUhXA8N1F DEWqkvKXlHnbBit4GmUTF2hwz6Ffvo+FCGIMJ/KF1CdGbAFLQUCvFVvfGH3qsfBxOt3r V8Rbi1XaULMUobV0ojxOAu5q3G5yrFC4wKUJQfHsxD4n93vb7kR8gWGxjLHy36wMeJfT PdVgtt7WRtptsXcNPNDKO4MvcKgtA6Vuhotn7hpUFZ9c/DJb1ICghPReboGuZ1dM38Az d9iA== X-Gm-Message-State: AGRZ1gLSPbUZYgz1/l2kGqq3gsvZUNrewm4TSA/V6G5WprRI9g7e4bjU I4FLlvidSgSRQKUIs+UXUOlLyFvI4DSDVAqTbviAmbdjLSRTbS/s681ZEaONwS3jdSZyjQMmcb6 g/oeqsl67wi4UAGx3F5L2r3Cx9uJARDhRQhpp3Xr59unuMzWFfPWF9zeC1Dbuk+o0v2t3s/igR0 XjPyEDSB6F58wYF65Pdhl7ikbC4jRVCLjduGBefg34LJuaXB0uN8Xz6+W+s9ur4RdrLuqwHvF39 JRM6iASXjt2WSLX4Z7DDMgbLY4m5AKo48hxfbrpwMF4hnWbAUluq9cJJdJSAOzhs/DiyS+2c9SD z0lPlR22T3KZWPc+gkuhvcSIFljqrajg+/mhvN7nyfm/+EkZXEaA4SFzqcGZSUGDFxdZKd+hDuE G X-Received: by 2002:a02:a98e:: with SMTP id q14-v6mr17366586jam.109.1542588498268; Sun, 18 Nov 2018 16:48:18 -0800 (PST) X-Received: by 2002:a02:a98e:: with SMTP id q14-v6mr17366564jam.109.1542588497683; Sun, 18 Nov 2018 16:48:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542588497; cv=none; d=google.com; s=arc-20160816; b=XazlPp3fshb557pYYWJNHWQR6w/p4BXzkjrSkAqUIwebSI8ljWu2x/Ja9eoBu7L5jI aXvhrLpl9TCoOYl/VRGY/xkFFpHLTyCHOJp+d/2LbCOEjh01KS/Bda4BVYDJkjaOFil8 veQXT7hRqypcHPyQSUwNFlqBI1A8Qi6cXQQkqAFoOQLFmuvVDeivrKRJLobdriRhaog+ cndbP7+AX0fVV4m5E8pmy2H3Vt1keydrEqBWTuWQ8zSqEfWxplettlYknJY+fsSxae6s 0GEhcO+R5tlCf4ngfEgtDGqrvW3dp0WHzYHV9268w/PFcAF5Su+wpWgbJLX3SzJXeXlG i3Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=6gyrhKbOCiv+zElf5LSN4Pe6YN3X6Cu7b8UNoJgG0NU=; b=lauxg94lZ0ixgRwlh0Oy2icroenf6RlbkHBHdATpXtv+Js77717WmxJN9ea6Lbs3Ng foYiMSctUBeNQauv5RoaRVdPIt0xOSR1j+9tW0c6lhpyMvU1gwWA/eHZZRY4RBQleIMU T4RcsDZTt1yV6dcLbPteN5iKlnDF+FnDyaHISARr7aXTN0Zcxaqhbm98yw2imMQeFPk5 hB0NvtAn/9NiD5cF4tciJVcAgO4BBL38eBw9ystf/rzry6/WhO7JXh0f2IK5QIEH60Jn TvGH/Tw2RoQ9krmYt8VB5brugd+H9PgARCadK7qICt6go2MvUVsS+ZaN1l2ixXlyDIJN oUbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=k1eHX+Vg; spf=pass (google.com: domain of yuzhao@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=yuzhao@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v195-v6sor43183485ita.7.2018.11.18.16.48.17 for (Google Transport Security); Sun, 18 Nov 2018 16:48:17 -0800 (PST) Received-SPF: pass (google.com: domain of yuzhao@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=k1eHX+Vg; spf=pass (google.com: domain of yuzhao@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=yuzhao@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6gyrhKbOCiv+zElf5LSN4Pe6YN3X6Cu7b8UNoJgG0NU=; b=k1eHX+Vgpl6WqlGfklr+LQkfRN+om2NAXFgLvgZuRRiFouWlHWPJDk7oeAbgB6SLJH r9lA2AKOiIBm8M5Ixs9Y83pSnPTw8ikNZWvcmxZww8SLN5+woqPipX45LQMQx/sWmUlk 5uULmwNZLvgGSGTZp2dLT9TbWWmxPIzzxRGdHHHO1Nt4Z6X2RzlJMpdbJ2GHCp9jPTyN 5ALv6BtLY9nxvwLLGNhxz972JSB/G9/p9PIFIAJmlp0qqttrND/e3TiKnLFRvdYCKomJ xlPokBP9l7ep0sNJ3JS4DFVnU0YuYf3liqw6Utd+kvnrD2+nLTznmZVy3O+mlHkEXKx5 t9tg== X-Google-Smtp-Source: AFSGD/WK7PBcEewTJ4jh7nTDYY5yQHwbqXpw1B2TF6BYTwsLAQcW232FT01I4iF+tkYRYiy1rtKarQ== X-Received: by 2002:a24:1e06:: with SMTP id 6mr5785429itt.46.1542588497085; Sun, 18 Nov 2018 16:48:17 -0800 (PST) Received: from yuzhao.bld.corp.google.com ([2620:15c:183:0:a0c3:519e:9276:fc96]) by smtp.gmail.com with ESMTPSA id 131-v6sm13661320itz.31.2018.11.18.16.48.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Nov 2018 16:48:15 -0800 (PST) From: Yu Zhao To: Hugh Dickins Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao Subject: [PATCH] mm: fix swap offset when replacing shmem page Date: Sun, 18 Nov 2018 17:47:19 -0700 Message-Id: <20181119004719.156411-1-yuzhao@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP We used to have a single swap address space with swp_entry_t.val as its radix tree index. This is not the case anymore. Now Each swp_type() has its own address space and should use swp_offset() as radix tree index. Signed-off-by: Yu Zhao --- mm/shmem.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index d44991ea5ed4..a92c6ae26915 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1509,11 +1509,13 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp, { struct page *oldpage, *newpage; struct address_space *swap_mapping; - pgoff_t swap_index; + swp_entry_t entry; int error; + VM_BUG_ON(PageSwapCache(*pagep)); + oldpage = *pagep; - swap_index = page_private(oldpage); + entry.val = page_private(oldpage); swap_mapping = page_mapping(oldpage); /* @@ -1532,7 +1534,7 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp, __SetPageLocked(newpage); __SetPageSwapBacked(newpage); SetPageUptodate(newpage); - set_page_private(newpage, swap_index); + set_page_private(newpage, entry.val); SetPageSwapCache(newpage); /* @@ -1540,7 +1542,8 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp, * a nice clean interface for us to replace oldpage by newpage there. */ xa_lock_irq(&swap_mapping->i_pages); - error = shmem_replace_entry(swap_mapping, swap_index, oldpage, newpage); + error = shmem_replace_entry(swap_mapping, swp_offset(entry), + oldpage, newpage); if (!error) { __inc_node_page_state(newpage, NR_FILE_PAGES); __dec_node_page_state(oldpage, NR_FILE_PAGES);