From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B7DFC433E0 for ; Fri, 15 Jan 2021 17:09:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0D742238EF for ; Fri, 15 Jan 2021 17:09:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D742238EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2C4018D019A; Fri, 15 Jan 2021 12:09:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 274A38D016A; Fri, 15 Jan 2021 12:09:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 161AA8D019A; Fri, 15 Jan 2021 12:09:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0141.hostedemail.com [216.40.44.141]) by kanga.kvack.org (Postfix) with ESMTP id 014608D016A for ; Fri, 15 Jan 2021 12:09:14 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9917A181D68B9 for ; Fri, 15 Jan 2021 17:09:14 +0000 (UTC) X-FDA: 77708645028.25.crook18_560826a27531 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 72406180882BA for ; Fri, 15 Jan 2021 17:09:14 +0000 (UTC) X-HE-Tag: crook18_560826a27531 X-Filterd-Recvd-Size: 5579 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Jan 2021 17:09:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610730553; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mHLrJ5S0GG/KaPJKytrt7gQrBF3eoNX3484kaZfBHrA=; b=FYBPak5ly0/G1YCUBDhuoa1LIOIGPw7cjJ/+NyW/18XY3GogiDdRfuPKTfM8oFq0mHykF8 hzue0iuuqQ1NgHMEOr7BFcHpBu6Fagr2UAehOKBsrbtMsjoz0osIuPOazH+XCESgfH7sDo atsObg1pY5Hn3furj+b98c1gUtYxgHg= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-344-ugc9KSIuMu-nOfLBbWWsGw-1; Fri, 15 Jan 2021 12:09:11 -0500 X-MC-Unique: ugc9KSIuMu-nOfLBbWWsGw-1 Received: by mail-qv1-f69.google.com with SMTP id f7so8266198qvr.4 for ; Fri, 15 Jan 2021 09:09:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mHLrJ5S0GG/KaPJKytrt7gQrBF3eoNX3484kaZfBHrA=; b=pKbrRapuiZ/eSqAb9tkHpoQXvcBD+JknKnGxDfy4XPUBJh/Uvo9I/Yi8JhjnxpggYA NQxO3/U/Gm4hk5pMe0mQ+2ptVeRb8BCLFhKCyMN0U3c6I12r2HZ9tMJ5haKbeqThVDpQ oGyMUxohnbIONA9DOUPYlhEvBVPsUqk8FBER31mSenm0aZnO+dCIoSNnFx87AizZTWLS LKZh79Xz4SCAF1bLNPMyCUCpmzpbyv1loKFHp7jie4cUZENEMfdONiO7SbAzluuLpI1k iQmXN2jBnVjPnnXuZKGrWazi2Vkox8Xj1gHou5QpPOy7OR5o8oViU1WQNQ+AdpSsLywv EtRw== X-Gm-Message-State: AOAM533EM+ssdtBwAMlJFueKTLHdr12xLNkk+6C6jUfP5HWd9j1qeUvC h77sNgPIfzIf3zTpHVygU2y1muyxGxQuoY6iwnqp2YaPwmT+z2jdqgnE9gwwgKiOxvfr3hlPacr PRu3PKJfhBK0= X-Received: by 2002:ac8:488e:: with SMTP id i14mr12617641qtq.372.1610730551310; Fri, 15 Jan 2021 09:09:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsp9bEM5PMzBbT8M14w42+8pX/BLJyTHZkLiXgcRVTGoU7UpYGDMzrmgA0vG0YbE5PiQX55A== X-Received: by 2002:ac8:488e:: with SMTP id i14mr12617613qtq.372.1610730551089; Fri, 15 Jan 2021 09:09:11 -0800 (PST) Received: from localhost.localdomain ([142.126.83.202]) by smtp.gmail.com with ESMTPSA id d123sm5187840qke.95.2021.01.15.09.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 09:09:10 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Mike Rapoport , Mike Kravetz , peterx@redhat.com, Jerome Glisse , "Kirill A . Shutemov" , Hugh Dickins , Axel Rasmussen , Matthew Wilcox , Andrew Morton , Andrea Arcangeli , Nadav Amit Subject: [PATCH RFC 01/30] mm/thp: Simplify copying of huge zero page pmd when fork Date: Fri, 15 Jan 2021 12:08:38 -0500 Message-Id: <20210115170907.24498-2-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115170907.24498-1-peterx@redhat.com> References: <20210115170907.24498-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable 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: Huge zero page is handled in a special path in copy_huge_pmd(), however i= t should share most codes with a normal thp page. Trying to share more cod= e with it by removing the special path. The only leftover so far is the huge ze= ro page refcounting (mm_get_huge_zero_page()), because that's separately don= e with a global counter. This prepares for a future patch to modify the huge pmd to be installed, = so that we don't need to duplicate it explicitly into huge zero page case to= o. Cc: Kirill A. Shutemov Signed-off-by: Peter Xu --- mm/huge_memory.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index ec2bb93f7431..b64ad1947900 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1058,17 +1058,13 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struc= t mm_struct *src_mm, * a page table. */ if (is_huge_zero_pmd(pmd)) { - struct page *zero_page; /* * get_huge_zero_page() will never allocate a new page here, * since we already have a zero page to copy. It just takes a * reference. */ - zero_page =3D mm_get_huge_zero_page(dst_mm); - set_huge_zero_page(pgtable, dst_mm, vma, addr, dst_pmd, - zero_page); - ret =3D 0; - goto out_unlock; + mm_get_huge_zero_page(dst_mm); + goto out_zero_page; } =20 src_page =3D pmd_page(pmd); @@ -1094,6 +1090,7 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct = mm_struct *src_mm, get_page(src_page); page_dup_rmap(src_page, true); add_mm_counter(dst_mm, MM_ANONPAGES, HPAGE_PMD_NR); +out_zero_page: mm_inc_nr_ptes(dst_mm); pgtable_trans_huge_deposit(dst_mm, dst_pmd, pgtable); =20 --=20 2.26.2