Received: by 10.192.165.148 with SMTP id m20csp1922582imm; Sun, 6 May 2018 02:40:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpYr7C/U7LqelsSzjdaU6s8d14GLsk8AcvrAE591hrblunmQlECqZ+K/bnwxYtxwKNdyrgy X-Received: by 2002:a63:7413:: with SMTP id p19-v6mr26861888pgc.230.1525599628818; Sun, 06 May 2018 02:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525599628; cv=none; d=google.com; s=arc-20160816; b=h+x2AZUcaLcgb5jsqE0gaQtzE1gK5TcsirWlpJMj+/7LLJgmdqkJ86FEz69u/8jmoO fK7Dyfj0bSBEmvPa2vLKWIGRfmqVmE1iQOpDK2D3V6TlSZ2allKqXpD9Kf1/4itKPvse 4Rd+fvHMBIbjZS7vhME1T9RK28tM1SAmYfyl8Q3EjXOFqw40ecBGuaPutPQwLloO+/BZ JZLRSTb/nTga4XwzMwLPIMuIcugFqMDKWaIYOERn7VVil3AjGPMMIM/RaC8v7xnFCBWE yqYlKqWKIEwDLz8mh4AtrFlUFVun6ixF/Koo8AqDPKetOzQZ+e5t8sNL5LpzHKD86VbY GusQ== 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 :arc-authentication-results; bh=oMM6F3V1Ig/TCtPg6V37DUMHIil+RtzrHFr9F+f6xtA=; b=08XcfeJnS01fo+VUtBWyzUeBAOSGsQmZIDcxr8aKN9plCSm4FFzf0ENrd85F9haUxr 7LWXW+L0gN1R9DYO4VSvqATlxd4hOhKEvvxgAQpAMdXazN+3cl+yYM9kYNbfCltsZnku luwZifEgxcoREV1x0U3NOUrPPMGBFrJt8+X2ybhAUiUiKSC3niANt8XkU+4NhiKKBDrx nXol3RHdtW6TXyBpMge7EVoASwP1RSvX/gpBJZDwYO9rUVdPSjr8HtZSRWyMISXwrNFP FJoiUEkFXO5yPB/AafXs5xXTgF1Etxy7BjUWtynKPuFqJy9Kh+32/dfBm14lKti61QiM 3XAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Z29pT0MW; 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 n13-v6si10446842pgd.541.2018.05.06.02.40.13; Sun, 06 May 2018 02:40:28 -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=Z29pT0MW; 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 S1751267AbeEFJkE (ORCPT + 99 others); Sun, 6 May 2018 05:40:04 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:40781 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750967AbeEFJkD (ORCPT ); Sun, 6 May 2018 05:40:03 -0400 Received: by mail-lf0-f68.google.com with SMTP id p85-v6so1105806lfg.7 for ; Sun, 06 May 2018 02:40:02 -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=oMM6F3V1Ig/TCtPg6V37DUMHIil+RtzrHFr9F+f6xtA=; b=Z29pT0MWMyNb1oZrTSfANlZKFlIMzaKq74RJ0ru1Ruf4UUVLnnXP/8l/WPDfo0vXN6 2M85G5Zw1D2O/REIFIjnpt0iPjd1chxOpqTEKkE2g9UqOWVSt7eOjnrsjtIIbR7v71hS lwHRcxxS1639V6RSwmLgEGZnIHFdQApvmmK2RzidRTVciaNCK8n32Ue18ENFN/jeS3r2 C4uvUaVKa36Tl7k0xTEbQHI1A1CghLZwimkRsjK2Hbrg6J1PoYYRALOrM2dSLKYqfY09 sNkPkFehLFscf33wluk/s/xpCWiRBT4K2ITwyQayu1/nlVgf+CZT0aOyWDN4FBvVrMwm eBdA== 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=oMM6F3V1Ig/TCtPg6V37DUMHIil+RtzrHFr9F+f6xtA=; b=deoGmSY7JY/mrKsa8ZMJ3HwkOoQSrlgVxcmnYOHbgausKe2h/7CJ6vceZgrROetdCi AC8osi5p/k8w1BZ/suNzbNTeCMrlra2I4gDomd2F/o1XpVBPGeTXQPcAadIDEEjWmQCw nKq5OuqZk9d2c89LIM++gMDBSIMFQIFE5a2/Z8CD0K4cMr8xkomU+OuC4CwATU+OVinU T0BKdY85RIk7goBPiA59/2c4zjUOtjKaiYk78hLwg6MopwQcSvNkL99botPUTmi7MvNX S8dCaee01v71N68E/UTP/O0qTL/AAGvAhWZgcM+D5LVGPJmhUHDDbEMHVHkQNUZtuNtR fXcA== X-Gm-Message-State: ALQs6tAZGcbWyurpAD8C/hCZIDdmhZSMmhD4uiz4DVneTqgB2Lgyv1un FH05GTXNbTcrkAu86lRvN6T2L3ylUfs1Uc8jsyw= X-Received: by 2002:a19:1d84:: with SMTP id d126-v6mr22083880lfd.100.1525599601469; Sun, 06 May 2018 02:40:01 -0700 (PDT) MIME-Version: 1.0 References: <1525329378-1864-1-git-send-email-ks77sj@gmail.com> In-Reply-To: <1525329378-1864-1-git-send-email-ks77sj@gmail.com> From: Vitaly Wool Date: Sun, 06 May 2018 09:39:51 +0000 Message-ID: Subject: Re: [PATCH v2] z3fold: fix reclaim lock-ups To: ks77sj@gmail.com Cc: 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 Hi Jongseok, Den tors 3 maj 2018 kl 08:36 skrev Jongseok Kim : > In the processing of headless pages, there was a problem that the > zhdr pointed to another page or a page was alread released in > z3fold_free(). So, the wrong page is encoded in headless, or test_bit > does not work properly in z3fold_reclaim_page(). This patch fixed these > problems. > Signed-off-by: Jongseok Kim > --- > mm/z3fold.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > diff --git a/mm/z3fold.c b/mm/z3fold.c > index d5b3f49..a36ffa5ab 100644 > --- a/mm/z3fold.c > +++ b/mm/z3fold.c > @@ -819,6 +819,7 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle) > static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries) > { > int i, ret = 0; > + bool is_headless; > struct z3fold_header *zhdr = NULL; > struct page *page = NULL; > struct list_head *pos; > @@ -836,11 +837,11 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries) > } > list_for_each_prev(pos, &pool->lru) { > page = list_entry(pos, struct page, lru); > + zhdr = page_address(page); > if (test_bit(PAGE_HEADLESS, &page->private)) > /* candidate found */ > break; > - zhdr = page_address(page); > if (!z3fold_page_trylock(zhdr)) > continue; /* can't evict at this point */ > kref_get(&zhdr->refcount); I don't see how that is relevant, we don't use zhdr variable if the page is headless anyway. > @@ -873,9 +874,11 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries) > * reference to this page > */ > z3fold_page_unlock(zhdr); > + is_headless = false; > } else { > first_handle = encode_handle(zhdr, HEADLESS); > last_handle = middle_handle = 0; > + is_headless = true; > } > /* Issue the eviction callback(s) */ > @@ -895,11 +898,10 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries) > goto next; > } > next: > - if (test_bit(PAGE_HEADLESS, &page->private)) { > - if (ret == 0) { > - free_z3fold_page(page); > + if (is_headless) { > + if (ret == 0) > return 0; > - } > + Thanks, that is indeed a valid fix, but given the operation of eviction in zswap case, I'd prefer to release the page here and not in _free(). Basically we should bail very early from z3fold_free() if the page is headless and UNDER_RECLAIM and keep the code intact in z3fold_reclaim_page(). ~Vitaly