Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4681724ybi; Mon, 15 Jul 2019 12:58:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcMI1Fpxs+Ys8B5ZTT8FqlMEnWGG6HCXbMLiT6GtuY8x9C8b9N+UnmNnmWpiC+quCWixBJ X-Received: by 2002:a63:1045:: with SMTP id 5mr28655792pgq.165.1563220709986; Mon, 15 Jul 2019 12:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563220709; cv=none; d=google.com; s=arc-20160816; b=MH5HNfuBRyIYVKJz0PXGQeavmGw0mrfdU/gHmTpUXW/AeK3b1Cm9lGUysa13n8a5nR rWKPtu0VkiCVO7wULq2v1x40mW5JfniXc9OKRjfwkQ6qeIM/35dPsntY8T00u2fry16l HKkutIaANcJn/5lyoSyxsbihKf+W2dbd7tZGTuso7SupavbQv7q1tPXq7dV0h8eCOR0G mAurF+un03Mz8ihYZf2b9KosSWYEnF6j4gew8OIlQgMU8WLmoynVFwp/Wo0N15tXYAgM 4ifDbhrypJrDxpY8eMQrQ28+03AWDOvaFVV+PYtSE9n+vabozMgd2AGbHreqa4BUSqse 6yOA== 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=7Sug0O9NXLo3GeKUfp2V2/QUpa/FJDN6PQvg6dxEhGs=; b=vXkDJ7TBIQqnv3YV2JE41429d6LmAfwtD9Ad3Mcnl49kZNSkwO8aOuegvdNux8yI0/ OY3pOhrhQ5ha2POcqvyTvXY4dTww0IL8f/bIItjXN5BAAFFw2Kr8bO4rohb53bt2cbKq 2kkU4GrPGkxl5t5EanZhQ7zUd9iHvZ2RjxwFBqY1GKeACEnWfD6MiAcuRUuruirXKa+e QC71M8MlUKljVOUF3CDG1w10aBI491qM98SIqCpcQndOuz6idKxyzggoT+7STJvqerg/ 6QrDEcqYkEUHHBO6WgMiD/PptxVjgt+aj9fvqBjMcZrgAG2dsjFKWvckyvj5RjmHC3kB NmRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uV4cZMJq; 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 w6si16822905pgf.193.2019.07.15.12.58.13; Mon, 15 Jul 2019 12:58:29 -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=uV4cZMJq; 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 S1731287AbfGOT5P (ORCPT + 99 others); Mon, 15 Jul 2019 15:57:15 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:42330 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729525AbfGOT5P (ORCPT ); Mon, 15 Jul 2019 15:57:15 -0400 Received: by mail-io1-f67.google.com with SMTP id e20so5803051iob.9 for ; Mon, 15 Jul 2019 12:57:14 -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=7Sug0O9NXLo3GeKUfp2V2/QUpa/FJDN6PQvg6dxEhGs=; b=uV4cZMJqpsv1MaFd6v3yIMTqWIdAaQKIAguNPDlxTnTIC7WgDs4hnszEFhEP1JcRgq u7tJH+guqw7uOY1t5dCh/8S+VG/+9gq/kkF+RbwCRLUZrmRac3qEWDUKafrdlxPiW6f1 FhdLcaiZFwkGJ71CzFhmIRnms8ERdOCuXugS/njWjnffoKHD4BeD06b5Ztz+fU5Lgolu bu9CZCMkq5cr+8jmfMltSA1rUZi58yYyGh6AGIvt/sI9mhnpOyLRhbBqpr+R+AhoX/bi wzN51uAobFbcd30yeizl7wg/YGK5C+TZfHTL1Eeyz52E0RslOBCTc4xNlWoY+LhNBU8H mbXQ== 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=7Sug0O9NXLo3GeKUfp2V2/QUpa/FJDN6PQvg6dxEhGs=; b=Aehrf9jdaW+M1z16is9Fq2rsz0rohVR80FmWKqlGHYyo9FDScq/UcGrb+WLXBJYIqi 4Ii5kft0ACScYl1VIpkTm1nMWz+XHW8fe2Y/RAIhBEpYNM6FTIQxRL2oA4j3OD5+tu6M pE9Dm0jOqpHQLknjG1ebxwd5QPjOAHJcbGasLb8bjnFu9LkoS8qGNquJCsWvVvjRweLA R9eztgRFhdnYALPGrvMuBMm0suQ3qXI+p39Jm3l8sc/z0Q2TDJ0//I2+YUD3zKsvlXS6 WtNd9WF922HqIVO7PjhfC5LxJXaqlmtz8bcd8gZU86onHAsb4Jp/nDm2Gs3kUNVKNHYG wYtg== X-Gm-Message-State: APjAAAVRLkyPSI5EKvqPgWmHkQPxDfVuiZFzbqRY38MHCxg4cZ7M43H2 jD9t4yrOt8PPstZQFSa0BymzIa0JmOv22+nTFkHMzA== X-Received: by 2002:a5e:9b05:: with SMTP id j5mr27098490iok.75.1563220634269; Mon, 15 Jul 2019 12:57:14 -0700 (PDT) MIME-Version: 1.0 References: <20190715164705.220693-1-henryburns@google.com> In-Reply-To: From: Henry Burns Date: Mon, 15 Jul 2019 12:56:38 -0700 Message-ID: Subject: Re: [PATCH] mm/z3fold.c: Reinitialize zhdr structs after migration To: Vitaly Wool Cc: Andrew Morton , Vitaly Vul , 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 >> >> 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 >> --- >> 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. >> + */ > > > On the nitpicking side, we seem to have ensured that directly in migrate :) Looks OK to me otherwise. Ok, I see it happens in the call to do_compact_page(). Got it, new patch coming out now. > > ~Vitaly > >> + INIT_LIST_HEAD(&new_zhdr->buddy); >> new_mapping = page_mapping(page); >> __ClearPageMovable(page); >> ClearPagePrivate(page); >> -- >> 2.22.0.510.g264f2c817a-goog >>