Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp3365626ybg; Sat, 6 Jun 2020 20:13:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYa0s+olE0c52RKldO3TH9ZVPCyt4YUr0/eny2qvTxLxxOsql44qiuD9LOC1VS1MMx5Jik X-Received: by 2002:a17:906:81c8:: with SMTP id e8mr14691892ejx.361.1591499619206; Sat, 06 Jun 2020 20:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591499619; cv=none; d=google.com; s=arc-20160816; b=Dd7O3iqUYvKzBY9BZJ5uLSECiHy7UjuHA3PEm0pyvdnRgOxDRnRdp+o0XaYZREQxBP vn3EDr8w7L8jv6SGG9r0cl69RBeW+j0CcPLAUA7wkB2FzJTLtDIk1q/H46oO0uL64O7x 5rwKdqobRURtHzQ2JON5pS/pAccZovBmn8shxc/U6l5VOfud9pcCCmukZ7Q7Vfebq5Q/ gvLGzzAU2Pu/AAd51r8yaebEiI+2AfNFGSMpMQx6qHLw89BQ6TTg6zmvgOos2/1X9zcQ gAgyvJYq3FKy/O8i6SH1wdkOkc0E73j6e0VaD/Z099eTECo5QSSpjpR51+EDZj8DrGjU 6FEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=S3FsUUp8iXLmWySNCgqZUVANUjvem9zIZH7o+aGND30=; b=cAbpn0CCd/KZRfAYSHBScsvt96DQ9d0OROhEoah++Zeuck0K4GHySJPCnHQoaOdMNC ss5Svvei++4OWxK+85Vm0JP6Krormi/WIHWF5Yq4zedaaUkg0bjqPswgqxPRUiOQpCj7 O1OSEYe7V9PDVy3BVceuHDaps4sQ6S58d0ynZ8BICUPE9M2R1JbDhYXSNda6Ni6i7SWZ jS+O6N0wgi7vuia6W/bnh2otF88iXdYL8e4t07yMK/AZFbo46D/nedvGV9tmrbm9onmO QChYpqGt+Im0/iwP/vMggI1b87qilcbnTmT/3vyauAxTvCm3jCjmfGSyLfnnUavG6B3e /e9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=q4dNKWO7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l21si6553048eds.400.2020.06.06.20.12.51; Sat, 06 Jun 2020 20:13:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=q4dNKWO7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728933AbgFGDE5 (ORCPT + 99 others); Sat, 6 Jun 2020 23:04:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728899AbgFGDE4 (ORCPT ); Sat, 6 Jun 2020 23:04:56 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78045C08C5C2; Sat, 6 Jun 2020 20:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=S3FsUUp8iXLmWySNCgqZUVANUjvem9zIZH7o+aGND30=; b=q4dNKWO73dvv/w2gR5rVJs4uHc SSRMpCrEhQJBGJNJHiXI2ImHh5CIVaaFicv7gtGSZ0lonH97AaIFXeQUsJOm0csmj/8RqI6I+DNVl X185hBYPYnOtmCup1cPrexAyQtT0zc9hDY5o195HKK6PKWWq4WNNoDvu/WlqNfsZlgF8ejf9XJEQy /rvBf0Efdbmmr2sL2ShPseC6+L9WMlfWFE5KWaGLJgVU3koUMYaYqMVVpTJyRwyT9hflXRlaKfkCX 0zbkAZcHfum4vM8taTDEij3C9A6bxIxJJRr1kv6u+rXYYQLHj4Jvq+jNBLfQDljRtlEXjhZ4W33Lq kWLAFCzw==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jhlcB-0008FJ-Eg; Sun, 07 Jun 2020 03:04:51 +0000 Date: Sat, 6 Jun 2020 20:04:51 -0700 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 18/25] mm: Allow large pages to be added to the page cache Message-ID: <20200607030451.GR19604@bombadil.infradead.org> References: <20200429133657.22632-1-willy@infradead.org> <20200429133657.22632-19-willy@infradead.org> <20200504031036.GB16070@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200504031036.GB16070@bombadil.infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 03, 2020 at 08:10:36PM -0700, Matthew Wilcox wrote: > On Wed, Apr 29, 2020 at 06:36:50AM -0700, Matthew Wilcox wrote: > > @@ -886,7 +906,7 @@ static int __add_to_page_cache_locked(struct page *page, > > /* Leave page->index set: truncation relies upon it */ > > if (!huge) > > mem_cgroup_cancel_charge(page, memcg, false); > > - put_page(page); > > + page_ref_sub(page, nr); > > return xas_error(&xas); > > } > > ALLOW_ERROR_INJECTION(__add_to_page_cache_locked, ERRNO); > > This is wrong. page_ref_sub() will not call __put_page() if the refcount > gets to zero. What do people prefer? *sigh*. It's not wrong. The caller holds a reference on the page already, so calling page_ref_sub() will never reduce the refcount to 0. The latest version looks like this: + page_ref_sub(page, nr); + VM_BUG_ON_PAGE(page_count(page) <= 0, page);