Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3145700ybi; Tue, 2 Jul 2019 02:54:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrYc0tRtQKYlweCPtsuV+BzhNs7lAsl7QfFjnr5M410BXA5ES2d/c23QBioVVziRpFtfqN X-Received: by 2002:a63:d24f:: with SMTP id t15mr26913871pgi.301.1562061287968; Tue, 02 Jul 2019 02:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562061287; cv=none; d=google.com; s=arc-20160816; b=ajDopb/Nkwnr/RvtZfnAW2CZz0HF1MwWkL/sMFohaD27lixJ29yyDn3plH5Ug/YD1R qIr/qiwgmNT5yQ0QKPYlsupl4nlAgUV/o7ZdVrjE616L58492U/ZtJVPvo4VAZJAMn7C MaWSVmvl8tx/rw7vgjTXimOlTkI/xux8ydy3uMJcCwGJTNGxpZZ2QjCCgy4RkFHFWHkf opxbo/V5f70Kr+fv7HWxpnbXgbirPKRhWLP8dttFFijqQE2SerkoFoAQfv61HaVbLkIl 4owz4X5YhrRLVXSHAUYReT0yNgH1w9xDhXAN7gmKNmbFPqs/46py4JjbtEX9wVLGIEzR 2+CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hjyKVTfGLIvonwBnPeklb1p3eTYs2YkOVqXlW7TXq5I=; b=gEaFzChBgr1WqBpvq1OB0UHaRov/llKAS6l9gtndCmBIgB0dcoBTnWls1QyXJK1njc u55M6/DmwmyYbuK17QFHCzHlh7tPMV/k6HfrtpuVgxtgvLETO8kbZaBbAnj2+gpsMqDY /R5izkmmQnjERFUYoGAjR4sLUfbIUoe9HVgX4rXl50WCRot5mDjzRd8eZjH6wT3oom3o zkIe7O5S3dC6jPB8Wo8DQBsW+eO1udZsTp3AskLVzZgaA7oXGm+C3qyt7dWYXgeXKlun CbzD06UM81Dx4KZh4enZHxjGTW8HNv6T/zWj4HoaafULvd+QmAbWJiklBW/Z+JOzJYqN AjkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KDkySTJN; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13si12305052pgd.347.2019.07.02.02.54.32; Tue, 02 Jul 2019 02:54:47 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KDkySTJN; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726980AbfGBJyG (ORCPT + 99 others); Tue, 2 Jul 2019 05:54:06 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:38416 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbfGBJyG (ORCPT ); Tue, 2 Jul 2019 05:54:06 -0400 Received: by mail-lj1-f194.google.com with SMTP id r9so16226809ljg.5 for ; Tue, 02 Jul 2019 02:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hjyKVTfGLIvonwBnPeklb1p3eTYs2YkOVqXlW7TXq5I=; b=KDkySTJNPi9xp2C9AbgqC60PF/XlLQ5EkZL2DorhyaDXAZWlT23yYIPfStjb1pELpb mCt6Dw0DoiVH9E0SF4LlIrX0Qg/iIO4boobYYGgAwfSUTcsn0iXNwkW0tj6VYZOQyIxJ /4JMcJsCj17lggg5m+gtFf24FOocdJjTtV1WH/HxcaH675SYrW59q555fZDLlfk5v1xz X/OxWEagVMcjk6FONjuM7VNPBOhVAULnNjBwbn6W7429kkDrpbgwYOw0LUYxZwLDEYen UqnqI9mCajyZkBl0t7/k3WXjxkERDDuwlXPAGc6Dp44e4YV59PKX2b9rkuqatb8B1oYO dQ4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hjyKVTfGLIvonwBnPeklb1p3eTYs2YkOVqXlW7TXq5I=; b=fq4hBjcTWIDj634a0ptkxNZ+7xeFWCwGCNTZrP255icS5fc2aiMwxBeNJaPO6+BYp9 rKjRZKjAkEreBeoJUJTGT7XdVwBZqrJ1PYQwaTJqWne6JopRxaSrtiSBmHfFYg2LwwE3 zjHuFlJyYuMv9/PwYARboL++bDMZK5vXCFbo8vE3r79v/qRKYX7eRH8mp66G/+qqEEgW j7Ed3p6b7479+o6ovv7SUTDEfqOWOsN9PBZF3dO6PQKAR9amiCYK5rbn3Ihb9t3tvfFl zNVlkDIl0bKgcdnHhKjedDVIqxWJj3QO1XYHm2hjs3rgqbeDieBdoKWAW+j4B47hb9yh iCCw== X-Gm-Message-State: APjAAAWQfiWuWUZga/I9SF1bNzo67FT+Ftxxm70QeODW7z2z3Zh0reu/ XV1DPTG2OD6tHm8HAIVMKwgxWyfE3B/c3Ou3ajg= X-Received: by 2002:a2e:8ed2:: with SMTP id e18mr16909326ljl.235.1562061244143; Tue, 02 Jul 2019 02:54:04 -0700 (PDT) MIME-Version: 1.0 References: <20190702005122.41036-1-henryburns@google.com> In-Reply-To: <20190702005122.41036-1-henryburns@google.com> From: Vitaly Wool Date: Tue, 2 Jul 2019 12:53:51 +0300 Message-ID: Subject: Re: [PATCH v2] mm/z3fold.c: Lock z3fold page before __SetPageMovable() To: Henry Burns Cc: Andrew Morton , Vitaly Vul , Mike Rapoport , Xidong Wang , Shakeel Butt , Jonathan Adams , Linux-MM , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 2, 2019 at 3:51 AM Henry Burns wrote: > > __SetPageMovable() expects it's page to be locked, but z3fold.c doesn't > lock the page. Following zsmalloc.c's example we call trylock_page() and > unlock_page(). Also makes z3fold_page_migrate() assert that newpage is > passed in locked, as documentation. > > Signed-off-by: Henry Burns > Suggested-by: Vitaly Wool Acked-by: Vitaly Wool Thanks! > --- > Changelog since v1: > - Added an if statement around WARN_ON(trylock_page(page)) to avoid > unlocking a page locked by a someone else. > > mm/z3fold.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/mm/z3fold.c b/mm/z3fold.c > index e174d1549734..6341435b9610 100644 > --- a/mm/z3fold.c > +++ b/mm/z3fold.c > @@ -918,7 +918,10 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp, > set_bit(PAGE_HEADLESS, &page->private); > goto headless; > } > - __SetPageMovable(page, pool->inode->i_mapping); > + if (!WARN_ON(!trylock_page(page))) { > + __SetPageMovable(page, pool->inode->i_mapping); > + unlock_page(page); > + } > z3fold_page_lock(zhdr); > > found: > @@ -1325,6 +1328,7 @@ static int z3fold_page_migrate(struct address_space *mapping, struct page *newpa > > VM_BUG_ON_PAGE(!PageMovable(page), page); > VM_BUG_ON_PAGE(!PageIsolated(page), page); > + VM_BUG_ON_PAGE(!PageLocked(newpage), newpage); > > zhdr = page_address(page); > pool = zhdr_to_pool(zhdr); > -- > 2.22.0.410.gd8fdbe21b5-goog >