From patchwork Tue Oct 26 17:38:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12585325 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 6996DC433F5 for ; Tue, 26 Oct 2021 17:38:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0A93D6103C for ; Tue, 26 Oct 2021 17:38:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0A93D6103C 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 3E82994000A; Tue, 26 Oct 2021 13:38:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39578940007; Tue, 26 Oct 2021 13:38:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2610394000A; Tue, 26 Oct 2021 13:38:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id 12DA0940007 for ; Tue, 26 Oct 2021 13:38:28 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CFF9E2B341 for ; Tue, 26 Oct 2021 17:38:27 +0000 (UTC) X-FDA: 78739297854.24.B650991 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by imf23.hostedemail.com (Postfix) with ESMTP id CA9B69000381 for ; Tue, 26 Oct 2021 17:38:19 +0000 (UTC) Received: by mail-qk1-f176.google.com with SMTP id h20so15853833qko.13 for ; Tue, 26 Oct 2021 10:38:27 -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=YFzPbDbRL/x6ma5Ca6cfrOJFG3iWMh8fKsCfxaMAfk8=; b=YS8eDNpGNOgrhmCcfg9iAfefq9xkwMoUI89lf12WEOadcE9GDaOq+SrKS9at0LRDOq QvV0zAPSnq6Jhf+lzstiFxhlVkIwVx4nK7on89VHZHwKlMEIXw1zoSlurpwB9TvtKBTP JSu0GGc+AphS9BEpoZN/RJX+iu1jkmCQW74rf3K0Sg29I/WviQ0Q9/H9RigjK1eYZPsK rvQLAwaMnsYn6LyrWGHH+63AE9ls3BqAr0OcH3+O5Oc+JjwiD7aBNfJdskPJ+of9GbLn XPJjW6DABqlkPdAY4lnOphSbXTpcajPuRlVFi9DfIlW/62zNKjXbx+xO+cVxKhYlrd9U M/nQ== 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=YFzPbDbRL/x6ma5Ca6cfrOJFG3iWMh8fKsCfxaMAfk8=; b=Ird8vIS0bRkzfsw0D4qY2iYpfQNdz8VdK9F4XQXgJWvyuu/c49pNnv+ArAdIef4sEW R4UsCVj9xOWR91jlnC9rhhtgPgNPe4WQCsAe5kVbJgLNfTkr3T7BxdNQw83Rde1yaz2T 9cl0LKFBMadzaNHypCGNfW3WRH2Gz9hgpemElDvu8PO/eIxUCzW9KvihL3qXIOW/BtEI OsRyRqNcvuE2hMpjHTOjUyg3gu8+1PLk+A2n/ZttRBBLg6tpXxlX7H+9lh1C5ecA828/ rCXgzKg7H3zyJ5goCG4oJMChQ+gbTUyxKKpymMLxTEqMcG8c4kZArJZIVfqQ+ballT7z 6b9w== X-Gm-Message-State: AOAM532UM89WlONEWezIMR0IVLMauFwkKifVyU474Fy1qK5KThiqzXgg GstTV2gEsKDKz3Va7rCMoFHfmg== X-Google-Smtp-Source: ABdhPJzJ5B+p6Rwtjwrqe/0j7MwD86qEOkIZcZ9ny2M9nsl7064QiqLbNAf1+bTV9ovTuHVldv6+BA== X-Received: by 2002:a05:620a:29d2:: with SMTP id s18mr3823816qkp.418.1635269906887; Tue, 26 Oct 2021 10:38:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 10:38:26 -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 2/8] mm/hugetlb: remove useless set_page_count() Date: Tue, 26 Oct 2021 17:38:16 +0000 Message-Id: <20211026173822.502506-3-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-Stat-Signature: g5s1juttzsfjna5rjppc6tmx6xh8qpp1 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: CA9B69000381 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=YS8eDNpG; dmarc=none; spf=pass (imf23.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.176 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com X-HE-Tag: 1635269899-205478 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: prep_compound_gigantic_page() calls set_page_count(0, p), but it is not needed because page_ref_freeze(p, 1) already sets refcount to 0. Using, set_page_count() is dangerous, because it unconditionally resets refcount from the current value to unrestrained value, and therefore should be minimized. Signed-off-by: Pasha Tatashin --- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 95dc7b83381f..7e3996c8b696 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1707,7 +1707,7 @@ static bool prep_compound_gigantic_page(struct page *page, unsigned int order) pr_warn("HugeTLB page can not be used due to unexpected inflated ref count\n"); goto out_error; } - set_page_count(p, 0); + VM_BUG_ON_PAGE(page_count(p), p); set_compound_head(p, page); } atomic_set(compound_mapcount_ptr(page), -1);