Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4532580ybi; Mon, 15 Jul 2019 10:23:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4PpuM81XybPI255LOlpkPDMY4uIBQ3Exmj1vWW/eghhL5WWjvVK1fbxGm0cpBiObJYNiF X-Received: by 2002:a17:902:704a:: with SMTP id h10mr28938157plt.337.1563211437562; Mon, 15 Jul 2019 10:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563211437; cv=none; d=google.com; s=arc-20160816; b=ZR8+bgnT2/O1vpm0VXZXxF3dpHDBBiFcERHgpLO/lY1+g+KSO1fL5Dr6rgRJNRsASs h8/vYTzC/kMcQrnZijp3xVn6yLwFRoi5hIO/PzJ4avld+URxfSz3yWqglAGf6TsQDngU VTEv344sWYnd6VOE8KfROIcm+yKEV0sQc+wdXLMUwq0op/xwRzpwSz/zLrrX8HNgkIMC v9VqiTd5unyIhgxZML11W6xSeB0E3nGchUtNjLp7MrJAAp5BTxGf4ktQ0fjYeDD1Vcs5 k7sMA5yAwOQ9ZPGGt84QEfDz4hmmkPaa/Ya+kOY09xcY8IBVGbNuvUjHJ9KzfOEt7NkG eUYA== 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=UscG4WxjnjQLRRcfnLMqxRe1yzGwBuLWPpq8Fn0xt8Q=; b=FVq6Lr4RAh/rUd3nUXChBTjUO5XdEx9qRuKjVSjrnWXF6hPQU9uDBn9sxUj8W8kpMs 33Uv2XN0Zfos5r+zEdXYTegYzeTOiY1gkFJYBzSmOUCFfjbziL9UZfBK0noH8lokoqph wju494XBQQtjr4damo5MWOfL5ZHpGNUcgvOR2aUxHxW7Tpl/MQOzYZ3Lav+QRshDtKtP DZdBK7ZNNUToDfB1xCtROIlSRW54b2HBUL2lzzNMH2m1XCsXsnrfrncCdlUzbk4bay9V TzUuMGKGsh7V/fVi71lg5vCNWPLNQfnbW88fKF0jAWModgb0ZVgENunl9hHHRMyLSjG9 q4tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dCelnzTW; 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 d16si15640953pll.352.2019.07.15.10.23.29; Mon, 15 Jul 2019 10:23:57 -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=dCelnzTW; 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 S1731604AbfGORWs (ORCPT + 99 others); Mon, 15 Jul 2019 13:22:48 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:45898 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730566AbfGORWs (ORCPT ); Mon, 15 Jul 2019 13:22:48 -0400 Received: by mail-yb1-f196.google.com with SMTP id s41so3710068ybe.12 for ; Mon, 15 Jul 2019 10:22:48 -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=UscG4WxjnjQLRRcfnLMqxRe1yzGwBuLWPpq8Fn0xt8Q=; b=dCelnzTW9yVty3d0zlRTYG3AJUta/BwdSagZLphy7SUDCPw0lYhayrZl5azIY8Po6K B6PcLuuOJVyIxwiflObjLQxgwM5LdzBm9j2APNC/1sPWiDeIVumlaaSR3cBownQl1gZ7 cmNM24365G9Kw33r/XyMye07LnJCa0G4XuKu3nH+stcJAD3HS2uHdNOlq2NHdW329Kw2 jEJCSCUJ5tFA21J/y5+gY4zuSpH9pE+SJy2MUjCxIUX/v4EZqtd+ycfE4D0VdA/uMj+1 lQiPTa3FPre/OAiF6DLgOrahbWMjYOGi4K0cps9eFLAe/W937jrg8dyOuSOGvbo+fxxf TPWw== 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=UscG4WxjnjQLRRcfnLMqxRe1yzGwBuLWPpq8Fn0xt8Q=; b=MMOJjvwL176Sza2zrmPUbEG5lFZ3BAX8mzbGf9K2VsRHQwlktpmZpg3SlwBUQCndMe qyBbjCAG4xpRQfLxMioWy0uMifyg2E+1qqGGmLiUxomsOgWV8iadKw06dy3yrOR/WgNQ NmED8TDQHXC8D8TDo5alWGRCi8ulWadZcTnRDMeQisu4YE2D6Ry7cpXD+q9IACpGEUKZ h4tYcgL4qE1/7nNGviyh/XAXClqtqPwk41QlrQj4sFnC1mBhFGge87AfrOBZrw8KCCea /hTlNZAx1y3KTCWOcUNpFzos5CHxZjrQKWIsDmzkZqirnxis4TZTyQxH9V5NSLsiaVn+ rk2w== X-Gm-Message-State: APjAAAVoCrIzwCdvpw+vzb8AjARbX4iivG0E5jQrTTjkycTh6pmyXZ0A 6m7LoU4IwS0O+z02icpTScZdblva7Q4ERc568tskLA== X-Received: by 2002:a25:7c05:: with SMTP id x5mr16996019ybc.358.1563211367257; Mon, 15 Jul 2019 10:22:47 -0700 (PDT) MIME-Version: 1.0 References: <20190715164705.220693-1-henryburns@google.com> In-Reply-To: <20190715164705.220693-1-henryburns@google.com> From: Shakeel Butt Date: Mon, 15 Jul 2019 10:22:36 -0700 Message-ID: Subject: Re: [PATCH] mm/z3fold.c: Reinitialize zhdr structs after migration To: Henry Burns Cc: Vitaly Wool , Andrew Morton , Vitaly Vul , 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 15, 2019 at 9:47 AM Henry Burns wrote: > > z3fold_page_migration() calls memcpy(new_zhdr, zhdr, PAGE_SIZE). > However, zhdr contains fields that can't be directly coppied over (ex: > list_head, a circular linked list). We only need to initialize the > linked lists in new_zhdr, as z3fold_isolate_page() already ensures > that these lists are empty. > > Additionally it is possible that zhdr->work has been placed in a > workqueue. In this case we shouldn't migrate the page, as zhdr->work > references zhdr as opposed to new_zhdr. > > Fixes: bba4c5f96ce4 ("mm/z3fold.c: support page migration") > Signed-off-by: Henry Burns Reviewed-by: Shakeel Butt > --- > mm/z3fold.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/mm/z3fold.c b/mm/z3fold.c > index 42ef9955117c..9da471bcab93 100644 > --- a/mm/z3fold.c > +++ b/mm/z3fold.c > @@ -1352,12 +1352,22 @@ static int z3fold_page_migrate(struct address_space *mapping, struct page *newpa > z3fold_page_unlock(zhdr); > return -EBUSY; > } > + if (work_pending(&zhdr->work)) { > + z3fold_page_unlock(zhdr); > + return -EAGAIN; > + } > new_zhdr = page_address(newpage); > memcpy(new_zhdr, zhdr, PAGE_SIZE); > newpage->private = page->private; > page->private = 0; > z3fold_page_unlock(zhdr); > spin_lock_init(&new_zhdr->page_lock); > + INIT_WORK(&new_zhdr->work, compact_page_work); > + /* > + * z3fold_page_isolate() ensures that this list is empty, so we only > + * have to reinitialize it. > + */ > + INIT_LIST_HEAD(&new_zhdr->buddy); > new_mapping = page_mapping(page); > __ClearPageMovable(page); > ClearPagePrivate(page); > -- > 2.22.0.510.g264f2c817a-goog >