Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1393975ybi; Tue, 16 Jul 2019 14:22:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+HmxkqFPMSmLVKdr5u/kBkT8yOG72VnWT5BUA6wChU+S7QZIyeTThDv6OgY/XelXgyTar X-Received: by 2002:a63:e807:: with SMTP id s7mr35457833pgh.194.1563312124263; Tue, 16 Jul 2019 14:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563312124; cv=none; d=google.com; s=arc-20160816; b=MatnFZJQ5GQJ6GVi6yLYemz3LwGdlnoQ449poxwS0KIgGY+bqrRui1XBA5LJZ+cAof Gvkjqag0udClsrRNJRhHcW0fz30M2aYB5VnpTi/wYXgzfz/6PQn2A5Wyx3+DwwZyPqjt 5W3jcxjdtl7Afgk8fOKaVLi0RRnVJD89lEMjHBfT1N3nWyTOd5PZL3k8bPKPASFgWtTt hirI5qV3GsdhbtERKJ/mOjxVxADZU+TqGO4Km90bMqIf/hYSuJgLBuwPpwi3doN0i3bt u6SvYiZjE8oOJ67Ai8Zjg+zIs2gtY+j8RZ0KmTrp7patYMZ7BM7VV+aB8PlgmWLFfi4c ma/w== 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=JJ9YJBDa6TAoDZnqGKrJ33E8HHSw9cbft8xMZfhrH5o=; b=da52WRKH8Cv8yvvU+wuFqpT0yLDagDzTdt4PHiOBKfDyVclg2hWK5IauRrVKfYUvKv tO4WgA6WaGTR4ZTZcEiDSSJrPrX3PQ1xJqTIn0RfMP85ZYuHCrVq63mQeRJl9Jkt6QtC uaDsuDu440bqN+89PLGPL6x1Eyob2T7Lofdu6uTBc0aHbdHB1EJutMxoA5a7HwwXO2b5 H1Ft4G/wCrVGwXupfkirOgiSzR0Zfh4olK72RstXUtuZ3Ye29rC866/7vEY0ox8SbIWh khddxIIZbKEWnoxIP0xpBciIAk8rWFS5i8VnWj9SZ1EhP15us7qImH29FMARXqaXhWoK rTiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=mzkioEkQ; 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 u9si19806488pjn.86.2019.07.16.14.21.24; Tue, 16 Jul 2019 14:22:04 -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=mzkioEkQ; 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 S2388018AbfGPVUm (ORCPT + 99 others); Tue, 16 Jul 2019 17:20:42 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:41004 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728118AbfGPVUl (ORCPT ); Tue, 16 Jul 2019 17:20:41 -0400 Received: by mail-yw1-f68.google.com with SMTP id i138so9557191ywg.8 for ; Tue, 16 Jul 2019 14:20:41 -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=JJ9YJBDa6TAoDZnqGKrJ33E8HHSw9cbft8xMZfhrH5o=; b=mzkioEkQusJ5+fSK27pN+Vp0ac4Y/hSwdtz9EBb/CGG+fQfnQpfNVJ4Nrn//Qzq2Sm ylEq8N1PhAUCbcJRX7iDYz/lqELXX2RiXjjyA9ljx3qmwq0sONvfWl06a0Mn5ntJGU6S HM8qXNVmfSIdYce6w4BJPgEs8i9O3VairrVzwHC66pvik4T4SSVAO2jeohAOuANIq7P5 cOsnhIMLJ526MbaDy6UjqAUEBr5hfXPe3Pucn/DrRLtbgSOnYK2+TE+ycQrWwf/kwoyM viQZLFx2ns8ebYgjZTz5eJCXtIgbh8+iMOJJfoPte0qOVJWIBE8ftoyCOtoXBRrl1p2k qiPw== 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=JJ9YJBDa6TAoDZnqGKrJ33E8HHSw9cbft8xMZfhrH5o=; b=EGbiUvbHjot4SJFNrPaACxQNLgau2n9+bW3VPoUq7lnqt8daO0kb6fTcqsPHNHpJZ1 Rth9609go2JtqhfehgEsCMge7aQgxkiXlRI+B/LridN0EtAy75eJZxZ3EzerOR/b8q7J vka1VeLlvn0zIMeyTP6dusoo2boAzuav9Yj8dxJxMxf83yhTc4YRnangKcGLc4pCqA/I FgMGddXDj57zdiq47TdLDfDgrViQLC/AkPNBGpkLTNTq1/5I5Bkc729lPHmg8BE5/d1Y ALSJcjJj+U2Zns9Mrz2nvt7II7ep57NNvoR+HIgCC3p1cr6LLJAAUXCNPRpTHweIj5cn BAvA== X-Gm-Message-State: APjAAAWdyVpeJwTKPejV1eyo7g2FXTLC9xrJurOtpHGaXZ+leXVXZ/QO UKlPn+5vm8juTXHL10b7wC3pDg9U8hg7SXoe2l6u+g== X-Received: by 2002:a0d:cb42:: with SMTP id n63mr21966936ywd.205.1563312039498; Tue, 16 Jul 2019 14:20:39 -0700 (PDT) MIME-Version: 1.0 References: <20190716000520.230595-1-henryburns@google.com> In-Reply-To: <20190716000520.230595-1-henryburns@google.com> From: Shakeel Butt Date: Tue, 16 Jul 2019 14:20:28 -0700 Message-ID: Subject: Re: [PATCH v2] mm/z3fold.c: Reinitialize zhdr structs after migration To: Henry Burns Cc: Vitaly Vul , Andrew Morton , 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 5:05 PM 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 > --- > Changelog since v1: > - Made comments explicityly refer to new_zhdr->buddy. > > mm/z3fold.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/mm/z3fold.c b/mm/z3fold.c > index 42ef9955117c..f4b2283b19a3 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 new_zhdr->buddy 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 >