From patchwork Mon Nov 19 01:09:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 10688151 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 59C6A14BD for ; Mon, 19 Nov 2018 01:09:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4917A29819 for ; Mon, 19 Nov 2018 01:09:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3ABFA29826; Mon, 19 Nov 2018 01:09:36 +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 CB80429819 for ; Mon, 19 Nov 2018 01:09:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C463C6B17AD; Sun, 18 Nov 2018 20:09:34 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BF5FA6B17AE; Sun, 18 Nov 2018 20:09:34 -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 B0CC76B17AF; Sun, 18 Nov 2018 20:09:34 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by kanga.kvack.org (Postfix) with ESMTP id 874826B17AD for ; Sun, 18 Nov 2018 20:09:34 -0500 (EST) Received: by mail-io1-f70.google.com with SMTP id u5-v6so29016183iol.11 for ; Sun, 18 Nov 2018 17:09:34 -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:in-reply-to:references:mime-version :content-transfer-encoding; bh=08RTZHbHI+FX7DFs4z5QY980a6/oJNTmgmTtWQcGnR8=; b=oipqEltZK9e323rHIivxmFQPdQd6wY2b1Jb0u+BQ6DDk89Cyfah8FciLmFQhyg6U5S 0P0Blz7L28p1PhIzi0Q3BWxR0c7uBcaN2PyYxfp3M53nCJsDv9N7hHRi3L752sOSESiO KY9ITJ/ZOCAhlX2yLi55YCCqZRWnl1M92sZm1+5ZVp3yPZ3P0xYv54VwIPsywbVLNYKf 3p/ZN0Yz4h194KgRZS/mcpR/Jgt1JiPSuDfKSAx17dSnKIorrvSBl0xLf2tJJXD4t57m GzdtoMDiVf8isKeDqU384jzBR1k7wv62S3sjGDzO8NPz43OIE1C75W0JkT/ZZIefmfmb eOCQ== X-Gm-Message-State: AGRZ1gKqfOIlItO8b5eMg9s8Y38sCf2mI8iyq0aQpm28DpMNbqX90LFo QDwxoj11elRs0HI5A00YIjwJdrCbD0aN9CNqz9Ns5aexqXijU7+TE4mqBj3/3FU/Jm7y1Yl3jee ZlnFs2udT0aFjo84G58FsPw/PmG5ytr/2iG1EoCY2fcWlbY91dFR72iCwtU2t1dffsYsSSIMI1m sVRkCC8/7Bh1iq5ICpogtrh8WHBb1jmJfqlYxV/bsPcO7mw6nG8R5K7QQ5LIXLYpgrqTmwcVUHI oNnsJizVQ1SdfnrNZAogoZpWlj3HoNneG0HDgHf32ViqiDa4+e91dldr0ntN5ozuBVjea8iPBt+ sUIq2tiIpg+7ysKbWHI2Wwy6f9XNE1WeXeDUN3QXrw7gWcQ2qgatZscdFxDczcvInLUHG9ridcE n X-Received: by 2002:a5e:8908:: with SMTP id k8mr15000740ioj.300.1542589774302; Sun, 18 Nov 2018 17:09:34 -0800 (PST) X-Received: by 2002:a5e:8908:: with SMTP id k8mr15000710ioj.300.1542589773714; Sun, 18 Nov 2018 17:09:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542589773; cv=none; d=google.com; s=arc-20160816; b=gYmNeYaazE9iBOLdi1HFSMwUiFlp8W0tBtbWqyzt2RuDmthtyMGkxRqKXuQrYtwXPC qN6zY06/AU47OB+vMqdtanj5udeLeSY/vChzcoHUooy8RKT8rbKdp6nCZ354yqxCeGJ7 wUtNOVvX4pyUngZg13O8f2m1QqdIuX16TBx9C0Kb0V0xOcvNsHqhjwVyzxmB24s88Upi 6JmnYxFnlpLi6yA7zxzbkD2OGIjGTWjhiHYZhN5kkOuhgRApSfcag6Ms8us1D0lSzY3/ VYXgO/V8lbAjfXKAKvAVr+B2x+IH9WZQ5OPjHA9tnxi9Py6GV+Hj54VZuJz+o8kxuinq Yn/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=08RTZHbHI+FX7DFs4z5QY980a6/oJNTmgmTtWQcGnR8=; b=cLl+0vTPl0ND8Xz23/7G0RLahPiOq60l4IOBy3dY5cZifBOn40Oix++u1Rbx/rWdV0 2bjqrZWYqbVS8ycmI3ue705LKfzGtMuxy+HllcjTdzf4VQm14lsP0CHAc8Lz9A6DDSqH scq1q64kVqAYfkdO3sJAXCgt0VE+uWYKa1A2PZOQo7z442GmrjfTD1C0EmMDXbLopt3S XIPPLXitu9IUrBN3EHGeHqU/0Xu28ckPiy0hPcX1Gb06suxqfbMDF9riFAbIjBZsMzjf w3fMTJcaK+zQCTlqsN6ayQfGDdOhEboKXp153MabXbMonF3ZP2YAzApwP/V5ZHKMTW2d uAMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gWjOa9pr; 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 c17sor6733807itd.32.2018.11.18.17.09.33 for (Google Transport Security); Sun, 18 Nov 2018 17:09:33 -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=gWjOa9pr; 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:in-reply-to:references :mime-version:content-transfer-encoding; bh=08RTZHbHI+FX7DFs4z5QY980a6/oJNTmgmTtWQcGnR8=; b=gWjOa9przldWulueeHOQsEz8sDSUpPVukBSbfAD00DxaLIJfMa6bbEbn7CC5BgIDxL gLm8uqvTQBvZDJx/bHHEsrpM/pMWr/9ZSl998FlZLudlOaRh/2WcCWKLHGG+ASm51eNB XT+DU8J6JplI1A6vNifzM0YgGfEyk6CSv7CQ9s+/ZFQhjZykV5rU8MQX7v7QRe8eoQT2 TW5jbOyY7NHA+m3WIqJROC9YyKN6aG46JdxfS6Uh5ed603q8xM+QBb+kwFurrbNCDgVL Whqercs6blapAX2SZe/KPM4GpzGT5xrk3IFfzHwsaKSKEmBd8hzKH3h6RhNYdKBoqA5r HEMA== X-Google-Smtp-Source: AFSGD/VAHNKNuVquGMvS36VKmk9MP+2etW7MFWrJAavXCkl6RCMSOLZSQtq+0cCPozlAg2stxEQBAA== X-Received: by 2002:a24:3796:: with SMTP id r144-v6mr6481688itr.79.1542589773265; Sun, 18 Nov 2018 17:09:33 -0800 (PST) Received: from yuzhao.bld.corp.google.com ([2620:15c:183:0:a0c3:519e:9276:fc96]) by smtp.gmail.com with ESMTPSA id t196-v6sm13946809ita.30.2018.11.18.17.09.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Nov 2018 17:09:31 -0800 (PST) From: Yu Zhao To: Hugh Dickins Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao Subject: [PATCH v2] mm: fix swap offset when replacing shmem page Date: Sun, 18 Nov 2018 18:09:24 -0700 Message-Id: <20181119010924.177177-1-yuzhao@google.com> X-Mailer: git-send-email 2.19.1.1215.g8438c0b245-goog In-Reply-To: <20181119004719.156411-1-yuzhao@google.com> References: <20181119004719.156411-1-yuzhao@google.com> 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..685faa3e0191 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);