Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2737641ybi; Mon, 1 Jul 2019 18:03:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVXXIrR1lVCBulcxmDMxfIOx9/n+ZokmnMEDGonLWe3XcWOCNEVuAAicDwWpOxHuIqN6kG X-Received: by 2002:a17:902:8a94:: with SMTP id p20mr31931170plo.312.1562029411697; Mon, 01 Jul 2019 18:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562029411; cv=none; d=google.com; s=arc-20160816; b=rVl9jaIAsoIcvQPikASHUqtsrxxCOBvw0cZq6RYq+x7Xl1U+3mAa3KjtVLO31DPL/X knzjVUU2+vnT2mqGNpSDMJDTOBMmsb+G8iKR57F1RWC6UZZ2me1j14x3XxOS9skFuQfQ 5+yVnNY6RUzHQB34jFUGkr2UuKlkYkdgGxuFZWo+5CQQpNqKcfdlNbWsALQhTYtpYFW+ YJxjY/bXLKJgmfSUjEUHKGHOeAkQZ6bJjpv1z+krH0cfKqYJ4T4n4/NsaSD+wqQ7VQBM qfiLZRqZR511124hs/dRo5m8TUWBc739gjmR06rzgCOLcJadmuRVG1AYmYXGE6Nwluag fs9Q== 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=YLKaclKnF/wxygehnw0ZhA/GQEsmphWVTGozX4zGxLc=; b=b+zrWCGK9iYlrc/Tk+7QeIvyiqxXiMTMjKaFwzHr8m7Wh9Q+l1InZJ0PnJwrfxXLdY Zb3gYrVRzxFuOMe8+DUsrN9pn5jziJKO7emO0aSAwXV9Wy64F9p6ittiqFEbOFcu7qUr 8pKmrv+6BsCzCD9pZct9Ep6z1dCXPIhj89Ot/APGEfmjMdLNbrC44Bib/LxLoNOq+rJR MO7347tTnRsbBb+qzZ0l5/4Q3WZBtto9XQ6k7TnSUI/vUAh04Qs0at/Seau0aVPHxTVt 9LiI3xEJF1bObG4GRP7cKo+dy1+J3g5N7WeUQYmGqQ5o0oqzKFH2nF8iLyHmRHkmcRpg /vTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=S0GY9y8C; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 188si11612083pgd.404.2019.07.01.18.03.13; Mon, 01 Jul 2019 18:03:31 -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=@google.com header.s=20161025 header.b=S0GY9y8C; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbfGBBAo (ORCPT + 99 others); Mon, 1 Jul 2019 21:00:44 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:35863 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727077AbfGBBAn (ORCPT ); Mon, 1 Jul 2019 21:00:43 -0400 Received: by mail-yb1-f196.google.com with SMTP id t10so741399ybk.3 for ; Mon, 01 Jul 2019 18:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YLKaclKnF/wxygehnw0ZhA/GQEsmphWVTGozX4zGxLc=; b=S0GY9y8C/Fi0sdyS/zcdqZr9tVAkG5ce7/IOGJ3enKy5/OPj2sokEMJIsSjkOxTADB +PtoAyiTYcYXDCup7vpukfHspqp6SPItVVG7fCAF9A7iH/K7i3vvprAhA5I61pfwHIct o0ZHa1L67jnNDgQ7MUaWUBb2jJbsO1a1qzkko2H6PTDkLBNOFIUlXB1hdoYyLycvv5uN g7VyrmxhBLq94kxQgJ39x6KgRKFiBHeg9BQNXXjtYiTLC8ExSo86WvdKD6UrovqjrGFG VzdM3uYqXrjYPX/v6yBewSkqjx/4mfssMGnUzTKLgYPCc3fgIIBf3gUIRChLsfhcY2Yp Mutg== 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=YLKaclKnF/wxygehnw0ZhA/GQEsmphWVTGozX4zGxLc=; b=FnRTh4aGd+hOwuIAYrJmfpbZOWIJq3i6aG/L9VgJklmYCPESMsYCQFHDk6XsEtm6Pj hIZU8KH5Y5bEInIZfdOrrrswZIpJyPIDw4jNWPT11g4YpMb3mYmOZiMlltMUyyZ+tUv8 j7gnwbewSYsG9ZuQvG2lUs/p2MU/WfDBSIMzJWuO+WE0+t9cigMn8dIY4DHwUdET/J2q BTLuy39ROB32AnYR4APanv+d9qNACS3Lg8XhHwEsUKtKrVhpqEQJ9baKNszug2sKzAh1 KvhhrmfLAj5oZajg2bdix2ify61VlCo4r1olGW/5FtjOQMGXpbPBmSd50x9V/C5lW5nh uGKg== X-Gm-Message-State: APjAAAU+OKNLSZbwTD7PLKDDADEmWMh8cPYx5C60Lx0/3N5a0KcxZjYK H3XUY5+OjWcZ8uHB2XM6hv9YuNKHPpFZ0MED06+faA== X-Received: by 2002:a25:7c05:: with SMTP id x5mr17362245ybc.358.1562029242861; Mon, 01 Jul 2019 18:00:42 -0700 (PDT) MIME-Version: 1.0 References: <20190702005122.41036-1-henryburns@google.com> In-Reply-To: <20190702005122.41036-1-henryburns@google.com> From: Shakeel Butt Date: Mon, 1 Jul 2019 18:00:31 -0700 Message-ID: Subject: Re: [PATCH v2] mm/z3fold.c: Lock z3fold page before __SetPageMovable() To: Henry Burns Cc: Vitaly Wool , Andrew Morton , Vitaly Vul , Mike Rapoport , Xidong Wang , 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 Mon, Jul 1, 2019 at 5:51 PM 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 > --- > 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); > + } Can you please comment why lock_page() is not used here? > 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 >