Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp42885pxb; Tue, 26 Oct 2021 20:50:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6P0PQcn8aCklIiCurE/ZYqZmGUr+tqv+rrGvBDKMj03sgZzf4af2VV6f/HHR2jF/fkPsG X-Received: by 2002:a17:902:8d8d:b0:140:638:a87c with SMTP id v13-20020a1709028d8d00b001400638a87cmr26085319plo.9.1635306653700; Tue, 26 Oct 2021 20:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635306653; cv=none; d=google.com; s=arc-20160816; b=Jxt8yZCwrS+uOB8NEBwhW764Mr7cMuKA6h6MCy40MO+wJA8VzsH9arQkFdsfW+G8Xm NtIWJvRGe4zC4Dba/GFvpbOtfMzQTe9y7Ed2VzE1OK9RQ/XFZA5UFCn9KnUC9mGOuVti b4S0ic5d4QOPPnlD4H3HO5rrzzs49JxXo1SYH1eHxELxXpzw104Rna9aeZuQb+hqmTMA uXxMtUud4tumSyyEvS5swqgEtjNQwzc2x+sx68Z3egzGCOtPOgGNMci67QpLNkVVWLlq lOqQD5kN3Jd5FUAdnoax4Dlyv8D39In4BswVmpmLKyr5ZBXO7kYn12JWJs3wgyaB+7vr /pBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=RTaUD2RUm6/em+jvQTkh6ivxttGsmNn09ntigKewekQ=; b=qvPx27+m7PgtmTD73dkvhg8XG7CTyZniO13ShfS8TIqhx+8qFyu6I5MUWhVUBFtTzD ElC/u6cKkZnAeZ8O0t9kssOTSvLocwCJQIu2pJQoLDmzDtGTBddZ0Nrplx/KRUyKPqWu r12g9EfhmHWgondX3Fh+MA43n3R2LuobLrA4iaqw21QmExc79rRE+uNwVQAL3GH3OB+k +stCma1aJyZu2d0U56MaMGOHsylavyJES7eGkROxu68kOkNvG/ddqumpoi+6ph4HCSac 3uKtbUxckFGHlkY684pSEqXWgr8C9Dq6Cafwy32CyGZdsl/XHMeWJvp7Buo78O3Ye58f HHjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=GIGS37Qo; 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 c18si1906584plg.264.2021.10.26.20.50.40; Tue, 26 Oct 2021 20:50:53 -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=pass header.i=@soleen.com header.s=google header.b=GIGS37Qo; 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 S237874AbhJZRlD (ORCPT + 99 others); Tue, 26 Oct 2021 13:41:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237801AbhJZRkx (ORCPT ); Tue, 26 Oct 2021 13:40:53 -0400 Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C860BC061767 for ; Tue, 26 Oct 2021 10:38:28 -0700 (PDT) Received: by mail-qv1-xf2e.google.com with SMTP id d10so5685357qvl.13 for ; Tue, 26 Oct 2021 10:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RTaUD2RUm6/em+jvQTkh6ivxttGsmNn09ntigKewekQ=; b=GIGS37Qoa3iQ9XGqYkImLqW64mhHkHZqcAdTsvWcZapxSea6btQvnnY5RgjopRu6dq PcqIvjD2ChFH0Bik2yOsB25Qz/PRL4pLDZpduH15i+44oAsfKQzQy77CjbE3RvfjtQ9w pZD5mtvVpkN0conJO3+cVJmm6e0g6QBh0b7JZ3psQzlo68/P7mTjqOozTJL5OLMSa12D El3xALwir4fVBu8/IaMqnBCrpXu/TCuTT4CVHK5gJIQlfjOXwvc5RvN1E6NEfnqYIuxj i4mmV1jV2cHm3QBFvK4uF/aAthF+7j6Tn/8+IW1HmzQ968lQ+O3l+yzPZYkM8cudcmV0 oRIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RTaUD2RUm6/em+jvQTkh6ivxttGsmNn09ntigKewekQ=; b=nsek8ZU4YH79T1/VrWNJHe6UlrGN3KpRfG673JgLWDUMn8N/R1Us4CXoFJqi9IOwFI KFzfIg6Lr0wWzGUHKFkUJh9kQx+vigwz+X3NJhXgd3Rnvxrv8+oImUn0k3DV/2573ugJ n8oo2pE/3dtx9NrWqlMvKOY7juy4l281A4Uo0CtanlDparuzul/avyd5ewTm4o84RplJ kB6MDocychMxD5ZkvKLpOuDKvgJ/fBwp54dq0/8YA/aDbesdRkz8NGIKCxrnfyWyoeYQ XudhKmzuPM1eJJ+FSretLiIWUC9UGu02JrDkPnigmtiRJzS/S9vri2i499VT8lZccDpl 1OYw== X-Gm-Message-State: AOAM533Hf5TUDOd7clkkbihhyXLTYn6/NTLywNIFLJg0AFKqxr2JFAS/ DHkimhDvx0t28yM0b9UolM5zyQ== X-Received: by 2002:a05:6214:23c5:: with SMTP id hr5mr24631556qvb.59.1635269907919; Tue, 26 Oct 2021 10:38:27 -0700 (PDT) Received: from soleen.c.googlers.com.com (189.216.85.34.bc.googleusercontent.com. [34.85.216.189]) by smtp.gmail.com with ESMTPSA id bj37sm11001939qkb.49.2021.10.26.10.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 10:38:27 -0700 (PDT) From: Pasha Tatashin To: pasha.tatashin@soleen.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-m68k@lists.linux-m68k.org, anshuman.khandual@arm.com, willy@infradead.org, akpm@linux-foundation.org, william.kucharski@oracle.com, mike.kravetz@oracle.com, vbabka@suse.cz, geert@linux-m68k.org, schmitzmic@gmail.com, rostedt@goodmis.org, mingo@redhat.com, hannes@cmpxchg.org, guro@fb.com, songmuchun@bytedance.com, weixugc@google.com, gthelen@google.com Subject: [RFC 3/8] mm: Avoid using set_page_count() in set_page_recounted() Date: Tue, 26 Oct 2021 17:38:17 +0000 Message-Id: <20211026173822.502506-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211026173822.502506-1-pasha.tatashin@soleen.com> References: <20211026173822.502506-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org set_page_refcounted() converts a non-refcounted page that has (page->_refcount == 0) into a refcounted page by setting _refcount to 1, Use page_ref_inc_return() instead to avoid unconditionally overwriting the _refcount value. Signed-off-by: Pasha Tatashin --- mm/internal.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/internal.h b/mm/internal.h index cf3cb933eba3..cf345fac6894 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -91,9 +91,12 @@ static inline bool page_evictable(struct page *page) */ static inline void set_page_refcounted(struct page *page) { + int refcnt; + VM_BUG_ON_PAGE(PageTail(page), page); VM_BUG_ON_PAGE(page_ref_count(page), page); - set_page_count(page, 1); + refcnt = page_ref_inc_return(page); + VM_BUG_ON_PAGE(refcnt != 1, page); } extern unsigned long highest_memmap_pfn; -- 2.33.0.1079.g6e70778dc9-goog