From patchwork Wed Jan 11 14:28:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13096760 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92293C63797 for ; Wed, 11 Jan 2023 14:29:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 063BF900006; Wed, 11 Jan 2023 09:29:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 648FD900004; Wed, 11 Jan 2023 09:29:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1EE38E000C; Wed, 11 Jan 2023 09:29:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 45BF68E0001 for ; Wed, 11 Jan 2023 09:29:09 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D9A311204EF for ; Wed, 11 Jan 2023 14:29:08 +0000 (UTC) X-FDA: 80342750376.09.3E98DF4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP id 59C8140023 for ; Wed, 11 Jan 2023 14:29:07 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=hVtu3kGA; dmarc=none; spf=none (imf04.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673447347; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kmo9D0eOQK4gl5x/N93BIarcQ1MlfQ8S0IUSdbRs2jA=; b=Yi4H0cwb9GrN4Dki2+6Y/OFZFse7mwKj5WJHuuQoQ9h+QJCt19Ru9j6bPq5Te6lULlXDYn M+T9qcB89S/Vd6xTlYo3ZuKza42RRB/Q0Fe1rYzHTriiQXdhA0bniY5oTMYr9W739mBl9N e3wqENl9RSnDfNkhqmLhGuBEP8Neea8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=hVtu3kGA; dmarc=none; spf=none (imf04.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673447347; a=rsa-sha256; cv=none; b=QMGpCUaHMY8i4hXH4TKs7qQ9Zr5GfS4uORGfWaFuxunYFp/T2IUV4EGsBylPMB1OEsAmHJ Kp2HVeEYMkUtY+SR6W7NHSdZytwmRoS5OuGWl67dCu3xmlwka0FjyPv2Jbmkv8RDlIpt4q o+5/enKS3FH0ZhO770mF7UvVcZx6PSE= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=kmo9D0eOQK4gl5x/N93BIarcQ1MlfQ8S0IUSdbRs2jA=; b=hVtu3kGAtuXR8w87XpIyiGCbDe S4LTCqI8a6fm3G11+cai1Vy4QulMK+MuaMns02flG/AH4NYVXddUwchZCRCTdvTxx0QBKja0pdHxC gKYYigCA1Vr06JTZWJdRHlJZdsLbZ3scprPcCk5KeinEfmCZsOL4Y7bAHttu99Nw+nvE96oaZ7gdP gCbO1PJ0yl3xA5HzBJHF+/bI7H99AneJaZtvDhhJQ9rN2tA+uOPowWinfZHuMYW+Y8pMbzsGlQnJB sFBSFcmnjU6VUl41oPTEN3erH59WsiFLrVAks+w+vqyO3v+oTZiqwZSevlFRoYvLDim//b2nF8A0m l/LNukJw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFc6Q-004CYf-23; Wed, 11 Jan 2023 14:29:18 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Hugh Dickins Subject: [PATCH 11/28] mm: Use entire_mapcount in __page_dup_rmap() Date: Wed, 11 Jan 2023 14:28:57 +0000 Message-Id: <20230111142915.1001531-12-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230111142915.1001531-1-willy@infradead.org> References: <20230111142915.1001531-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 59C8140023 X-Stat-Signature: y5xi5b9nchw8gmhq3qr5qej3jfjzs9xm X-HE-Tag: 1673447347-5288 X-HE-Meta: U2FsdGVkX19hYd5O6DH/bN4BZKEI1W7O6BI/BJP4Mwvjd/yGHlFrCeD7dkgnUecBJYtRbBqgTAfH/3i/DhGrVWn0Y+BdpH5Hb6MhgxwnJrNFTsCWHQaa8xx7sc0UF2KKLfKgHFKbCay8tSDJ7z7HQFUUM9NtWLtiQcKp/agwqf7OfQH+DKRNb6GUE1XHuVCaT2uU2bm7mxeCeim9ra3xqAVl+fC0GBWQ12Ou9TtdrDVHDcf7C81OIwEdWzlt2Uozfy4LeThUWp1R4OFDxnkxOH81xYqfmxqnCIViO6DbiTnP/aHoX/jFATSs7ygls73TUGLwQ9JFScZ8Tk0m/nBrQaPYLssa6U7cWBQkIIOmUJ403SQdqjS8d/+xX0C3KcVfpZLHKc5HSabpY5LCfbgJWwSySXgHGHb3p+4pO4KQGDU7IcNZ3z7WGgjg6cpeUMrrPFIN+MM21SDmcpDAAPEZyF2eemVToqJkESJ2zXvxtDUbrL0CQyy7X/1YPq5qsTBGvwowhM0EBW4mX2ESK0V6i7RoyfEjnntLY2kLaTNS1VCRNH2RHBtFtTO9yKafvZqjb5geum2PnLDx+480McQ/DTFwFb9qUV5/0ybFBd2Ay8OIil5oiuDSpa1r6DozQC9EiJD5pzjucJJVHBy2QhlzyTOeavNb9fm8LTz7F5FXSMKz5YxGideG5d1Z7sAO9Fd1dUjrYt3wgFVOqGzk4jpm3KpdiNZXESx7ejfiRN6IiDtS0/niWyaKR+G5GnK2aesr8vX1lJ8hOl+YKyDvAW6UXFJCmJaktdXODHGrpwKcESWmSD5HIE1zAhMnPG8D6dRb4/U4LkWLL0E7J1xVTb56/HmNawsrrBRfRfEhthDv/R2TH+nFRvj2Qp/pK3azZVZtzvwQBVjwMfWRuFaGZYRSrTYpPvRkUXfHjPOPQL1uDLk6BCIuGXMsMg== 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: Remove the use of the compound_mapcount_ptr() wrapper, and add an assertion that we're not passing a tail page if we're duplicating a PMD. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/rmap.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index aa682a2a93ce..a6bd1f0a183d 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -208,7 +208,14 @@ void hugepage_add_new_anon_rmap(struct page *, struct vm_area_struct *, static inline void __page_dup_rmap(struct page *page, bool compound) { - atomic_inc(compound ? compound_mapcount_ptr(page) : &page->_mapcount); + if (compound) { + struct folio *folio = (struct folio *)page; + + VM_BUG_ON_PAGE(compound && !PageHead(page), page); + atomic_inc(&folio->_entire_mapcount); + } else { + atomic_inc(&page->_mapcount); + } } static inline void page_dup_file_rmap(struct page *page, bool compound)