Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2669089ybi; Mon, 1 Jul 2019 16:32:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBtzmIZjrtsctOJGfjopKtNW1MCJAh2UT5VCRh4PzJUMvUuCnF3niLUkAso8vipVV5C2mE X-Received: by 2002:a17:902:8509:: with SMTP id bj9mr32045636plb.79.1562023973664; Mon, 01 Jul 2019 16:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562023973; cv=none; d=google.com; s=arc-20160816; b=qy4JPM5sZxyu0Bpkhff2Tn4voZpKk224d29uZBhsJVK+QsPOvhFOjQT5pRjWFA0MbJ bVGsS5GMq/RkaZ0R3lQRbfJXNSt22m9d0NhCWIUXJ+SdRvxwfl9h6EZqw9GM4bmqhntS WVpye2Ed4J7/PCFXO1RV2t6p4E2YqthTN7zygk+BmFd/rP30TtjBOIx5qqmbrsQS+Xd5 EYxLCb9c9pCETrxLEkkMCHmi3Vxom45BDmnHXbdvBCJJicOdywcXCR9+oqF2gy7trS7Y krxvvTb+lVO22Lz7rQt4EMgBjGEbosEH2t/yUYd7baOZ3vfHrPE9/8VB5awO8mEFa1jL sa9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=O0b2tWO1RIcCmvfvh2lXMb1E+ocfn4SsM4a6s7YsoIo=; b=Qy0jxTwbLrhe0B7sfQDzYdceiUSIO3D79gf0qSFKuYwUmaV/V5OJajfM4ILaeYGGYa e+3b2NM8O/8vbGxyd/E/kRQMTEboE4PQlThMWV8IdfN8Q5sGoO429fBsEaz9OdiYY96I 3yBg9jyLBck6bM+poHkdusWrcdf1NePAdLCtmdDda4AbfDwiCVVPXw4XM8rac7S3b4ee OmOPR3im095JDTiz7SQjfJ3B+xTi+3Yzr8JYtaCT5hrNo+r6EYXDsQtf1xwv+VL2Wvit d7VY3vDEt5emTRl+KxuRC6RE4BDX7TF9OxmYTEx79Fqa4pS1oLMnve5zspLorjmyBa9l zzkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yulAQMWr; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si723882pjv.99.2019.07.01.16.32.38; Mon, 01 Jul 2019 16:32:53 -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=@kernel.org header.s=default header.b=yulAQMWr; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726967AbfGAXcN (ORCPT + 99 others); Mon, 1 Jul 2019 19:32:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:55252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbfGAXcN (ORCPT ); Mon, 1 Jul 2019 19:32:13 -0400 Received: from localhost.localdomain (c-73-223-200-170.hsd1.ca.comcast.net [73.223.200.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E146821479; Mon, 1 Jul 2019 23:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562023932; bh=dBXpbIE1R4CzpTJv8obwrKm6+ibARscFWpAQm9lSQZA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=yulAQMWrcw1P+CopEJYaogBfFneJfl2za6FZd5pFA6D5io9m+xQnEm+yQaDWjdT/Y 9DFHXlk5mdBoyq4T6dTSKA58o6T74Hd/T8dTqYp/w0HOnpZqf6i5nqYGJuQ9bA1XgI Mo0ZF2H9lZFRsD+XZV8fRh2gemTtyGNq9stOi+ew= Date: Mon, 1 Jul 2019 16:32:11 -0700 From: Andrew Morton To: Henry Burns Cc: Vitaly Wool , Vitaly Vul , Mike Rapoport , Xidong Wang , Shakeel Butt , Jonathan Adams , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/z3fold.c: Lock z3fold page before __SetPageMovable() Message-Id: <20190701163211.e9e0f2cf5332c06640e3019d@linux-foundation.org> In-Reply-To: <20190701212303.168581-1-henryburns@google.com> References: <20190701212303.168581-1-henryburns@google.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 1 Jul 2019 14:23:03 -0700 Henry Burns wrote: > __SetPageMovable() expects it's page to be locked, but z3fold.c doesn't > lock the page. So this triggers the VM_BUG_ON_PAGE(!PageLocked(page), page) in __SetPageMovable(), yes? > Following zsmalloc.c's example we call trylock_page() and > unlock_page(). Also makes z3fold_page_migrate() assert that newpage is > passed in locked, as documentation. > > ... > > --- a/mm/z3fold.c > +++ b/mm/z3fold.c > @@ -918,7 +918,9 @@ static int z3fold_alloc(struct z3fold_pool *pool, size_t size, gfp_t gfp, > set_bit(PAGE_HEADLESS, &page->private); > goto headless; > } > + WARN_ON(!trylock_page(page)); If this warn triggers then someone else has locked the page. > __SetPageMovable(page, pool->inode->i_mapping); > + unlock_page(page); and we proceed to undo their lock. So that other code path will then perform an unlock of an unlocked page. Etcetera. It would be much much better to do a plain old lock_page() here. If that results in a deadlock then let's find out why and fix it without trylock hacks.