Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1160989ybi; Wed, 3 Jul 2019 10:31:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzJ1OmQqEFSWf36b9hpUm4mmFREfhQ4XEvKQ8XGdwKBTqEUs04fn5p1QgSYG9wNSXAeNYO X-Received: by 2002:a17:90a:ad86:: with SMTP id s6mr14190036pjq.42.1562175114557; Wed, 03 Jul 2019 10:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562175114; cv=none; d=google.com; s=arc-20160816; b=FbQWSNnWAAkVRsj7kFTGl3deecL70DgHxlvcC3tRAON+OlUwakW7Bwc9O9yjSV+gDX PnmHS760p10zBJyzjw+fKzQW5JQ9Mpl6tcX7PIfS5TD+xM/8FRB1P7/eE6kP3Jt+6ksl fLStbGTE2fIDGGRp3vvQeSQvXRHedkMNnQFdWcl5n8z2YQt0Nhu0d/nKs7lk0IeT+XrI F5tCZCY0bgKBo8DXNoviXXWb4Rt1nleVk2ezZHiOIjcevfqDa25dLc1+h2Ry1eb+Smir LcTrbR5ARVH9A9NG3yREvuBx/OAFnzpK2HcmupUSdY+RTj/2RVUuk/fqcnbM42ZR/2Uq 8pzw== 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=kbDcTo4F8dXvZfSLbaTtza62bmr8qH9H1r6LEOl+lHU=; b=kvc4WfBkiBJ7V/W2CQYodYppsI2W7xnPksHRU98WLh17120l7PBWbFqUXuMw0IvGkE Lv327vJb4JyMWkfO4vJygLu9y7lg/zG3X8qlwn8DOtVSVqwBEQnNTgwyCxVUat6j9CTP zSPE7GihFaM5PfiyJlGm9sfRMHjKsP7ld2CKJWUzThiWJHO64cpoa42wBjv7IN1gczgJ xKU6BOT/KPD7E5wsFnTo9Xr5+9G4Zff9xrRjOXnLOGpplqqH7WJKeJMA6foB6TN8NTab Th6Zxbdzmj0ZdChZh4xmB5Geak0LfS0euxeHwGLVzfaJehVBe6Z8fW9MeTuEPjaBN7gn 16+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="NqaumRs/"; 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 w186si2931914pgd.48.2019.07.03.10.31.30; Wed, 03 Jul 2019 10:31:54 -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="NqaumRs/"; 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 S1726991AbfGCQjt (ORCPT + 99 others); Wed, 3 Jul 2019 12:39:49 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:42865 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbfGCQjt (ORCPT ); Wed, 3 Jul 2019 12:39:49 -0400 Received: by mail-io1-f67.google.com with SMTP id u19so6285726ior.9 for ; Wed, 03 Jul 2019 09:39:49 -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=kbDcTo4F8dXvZfSLbaTtza62bmr8qH9H1r6LEOl+lHU=; b=NqaumRs/9r4N+LLQZVW7EKfaaKJYqiFXNQS0FREyFBH2dA5dQe+xDeHSF8h0f4HvVD ZpP8PimJIp+5sU4npv4xahYwMV9fygG58x2bwWCGYHMgA8d9jsiTXdEjgjXy50uJ8PsW TEbw48ERxWv8d1V3mw3vCrwh3vLxHeL0fTrQR+MYMu9XRa8KDsArTcgvh9andjUd2RP+ 5woe4LfbhzoeKMgNBcJVBChrKTb8DDZ1RbCyrhk++x3Je98AMpNOduXga2w48ITbLxqT 5lCWRmkcHTJKIQBXr5u7Wu9Iwq41eXIyXnTqbszIjP3xokx9W176FvHXk2RhCqMaUmCV qGzw== 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=kbDcTo4F8dXvZfSLbaTtza62bmr8qH9H1r6LEOl+lHU=; b=TYUDnhihWtoMkQd8L3J17mIFNWugdvqb7UYiUlx4/xawjAKQZfifpS89+6hthtKjO+ ROPxXWaFjiAfxbRsPUsHp6q6UYXXqi5lci2Oe990qN14RnJ6itFQ12UtedVph0sTwOO2 ZGIpFQt5Ug6SU6jyyuW5VpBJ62zFMKvU8rh4Ft3mmwZV4GbHLirE5ntAJiHUp7sqDW4B r0BzuJukvYwRF6b4SPnU9u7eQezlnDwPi1wDCKVhZ4KGQYze0UsijpgYNSpawGsLNQ1Q RIlwHoL2zVnbUV6ZX7JaCuMlFgHoIkSdIX+SczGrZIpWcFzCqj1Ig8xE3TAFF3WAea57 AnAg== X-Gm-Message-State: APjAAAUzbg64jcYPsuZkRmoTjHFfQb8KGqM01KBFT9ZQXPnVPz2pXK3B WC53HChxQVVh7RFXP61eS81L/+Z29+qVCi0D67FzCQ== X-Received: by 2002:a5d:81c6:: with SMTP id t6mr15956036iol.86.1562171988733; Wed, 03 Jul 2019 09:39:48 -0700 (PDT) MIME-Version: 1.0 References: <20190702005122.41036-1-henryburns@google.com> <20190702141930.e31bf1c07a77514d976ef6e2@linux-foundation.org> <20190702152409.21c6c3787d125d61fb47840a@linux-foundation.org> In-Reply-To: From: Henry Burns Date: Wed, 3 Jul 2019 09:39:12 -0700 Message-ID: Subject: Re: [PATCH v2] mm/z3fold.c: Lock z3fold page before __SetPageMovable() To: Vitaly Wool Cc: Andrew Morton , Shakeel Butt , 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 Tue, Jul 2, 2019 at 10:54 PM Vitaly Wool wrote: > > On Wed, Jul 3, 2019 at 12:24 AM Andrew Morton wrote: > > > > On Tue, 2 Jul 2019 15:17:47 -0700 Henry Burns wrote: > > > > > > > > > + if (can_sleep) { > > > > > > > + lock_page(page); > > > > > > > + __SetPageMovable(page, pool->inode->i_mapping); > > > > > > > + unlock_page(page); > > > > > > > + } else { > > > > > > > + if (!WARN_ON(!trylock_page(page))) { > > > > > > > + __SetPageMovable(page, pool->inode->i_mapping); > > > > > > > + unlock_page(page); > > > > > > > + } else { > > > > > > > + pr_err("Newly allocated z3fold page is locked\n"); > > > > > > > + WARN_ON(1); > > > > The WARN_ON will have already warned in this case. > > > > But the whole idea of warning in this case may be undesirable. We KNOW > > that the warning will sometimes trigger (yes?). So what's the point in > > scaring users? > > Well, normally a newly allocated page that we own should not be locked > by someone else so this is worth a warning IMO. With that said, the > else branch here appears to be redundant. The else branch has been removed, and I think it's possible (albeit unlikely) that the trylock could fail due to either compaction or kstaled (In which case the page just won't be movable). Also Vitaly, do you have a preference between the two emails? I'm not sure which one to include.