From patchwork Tue Oct 26 17:38:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12585327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 757DFC433FE for ; Tue, 26 Oct 2021 17:38:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0CDEC6109E for ; Tue, 26 Oct 2021 17:38:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0CDEC6109E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9169594000B; Tue, 26 Oct 2021 13:38:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C9BC940007; Tue, 26 Oct 2021 13:38:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74BD994000B; Tue, 26 Oct 2021 13:38:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id 64264940007 for ; Tue, 26 Oct 2021 13:38:29 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1655C18286210 for ; Tue, 26 Oct 2021 17:38:29 +0000 (UTC) X-FDA: 78739297938.08.A3AEFA0 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by imf11.hostedemail.com (Postfix) with ESMTP id B7A44F000201 for ; Tue, 26 Oct 2021 17:38:28 +0000 (UTC) Received: by mail-qv1-f49.google.com with SMTP id d6so10088710qvb.3 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=qwQfuhmsOG75YOsB/bx4qfQ8uynnHSQqsJ3oVtIsMfddUPR8YktxSlZxLcqCddAW6c hRPE8J6QbOEn+NtiZYvme/jI5bQEMyy7/37g3nEm563iudud+VJhzPAqahVcDetce7do 4RD59Fvwaoeug7I5GhTSUm4B9G9++TviDvVGzIGYGO38nsj7yeVzE0YwyClbG2Sy+vjU bV5aZUiZsIhrHAaojVfzwgigY5jtQt8JkyaW8hcOSPxWJYEhqnyQXRikl0p+abAglLs6 WyWRBsf/0dvyZWIIbqnwxkxFDcFhi2GnVdJY1TCjkI34f3V6HPGdWktJX4wb+iMzZl/c VzzA== X-Gm-Message-State: AOAM530ZOnmft/xvJDL1ONfxddab8ehxXB5vd28Ja7QOD2cypEjkGtUO jhXQDSrTAXk6Yr9PEjgmMymPIw== X-Google-Smtp-Source: ABdhPJx51qUHPL7MosY+ccdW2v8AQS7qpS2Lf6x9DSO9D0SE6bk4w8h6c+6o+lQ+QoMcJjSYsK+17A== 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 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: B7A44F000201 X-Stat-Signature: 3k3n6p7awrpg65caxwoh7kh53us5i9o8 Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=GIGS37Qo; dmarc=none; spf=pass (imf11.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.49 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com X-HE-Tag: 1635269908-601009 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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;