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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 2B433C433ED for ; Thu, 29 Apr 2021 08:04:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9741961445 for ; Thu, 29 Apr 2021 08:04:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9741961445 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 C833F6B006E; Thu, 29 Apr 2021 04:04:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C34706B0070; Thu, 29 Apr 2021 04:04:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD53D6B0071; Thu, 29 Apr 2021 04:04:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id 8D44B6B006E for ; Thu, 29 Apr 2021 04:04:03 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 41E644DDD for ; Thu, 29 Apr 2021 08:04:03 +0000 (UTC) X-FDA: 78084666366.05.ED58B21 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 80057C0007EA for ; Thu, 29 Apr 2021 08:04:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619683442; 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=yROuGbeUEgCGpxT1QPFa4L1x3UhTY7TTPslf1Y0MM/A=; b=Aw28oMvZ0vZIUm4lpse3bI2vvcDtghaFCn/o1WETqdIjURsUtdX9cRACUmFYJ6Rb04Yl1y E3rWMCl0GugRXoiRV7jgnnB2pu2FJfwBd+jWf1LgVP+kgte6ThRITw5A8xOXLYGaI8e7ge VHipEgsEE08GUjm2LRsMbLfHzY6Ioss= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-jsgx4-fwM7WWZy7okyBNeg-1; Thu, 29 Apr 2021 04:04:00 -0400 X-MC-Unique: jsgx4-fwM7WWZy7okyBNeg-1 Received: by mail-wr1-f72.google.com with SMTP id 67-20020adf81490000b029010756d109e6so12102632wrm.13 for ; Thu, 29 Apr 2021 01:04:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=yROuGbeUEgCGpxT1QPFa4L1x3UhTY7TTPslf1Y0MM/A=; b=iOyELDbHVbaBga7giB3hTKewR5RiSu57dhuhusgfuRZAO0kpcKJ2furvdqOGHTFxcK nbCQsW0IlBdFFJdzKvsGw3CPlphVlGPt8VU43uGc1sgE2rq70hxysrsXh50RHFqgSYlL CCgkNOnXb1enDaHSxbUWAc2hIdNAR1wFJ0hMzGnUzXUw+cBgbKw83gybnDU/G6UgO/Qv QT7WF8anPqiW3Q9ZYM4H1RXQcYjvOHWuUO09xAHEv9sXquMwO43AKgKtW5uFHxyAzHF2 HpNAgeB8SVLvKWMTDb51TINBNHnzioNbqZ8IFep3RiJ0q7btMCah1jR38v5WeT8mPFLH s4eQ== X-Gm-Message-State: AOAM533P34DQ88lGgnhJ+OrkfB6uFtLM5ofbliUftoz8RARTUa7K22Ep GuEhsnwrK3KFVhP9XiuUwDzObzdpL4nlPZ9SI3Qps84UJWF4ra079UmoGhwSM3/6nC9Yw5oHoIs NAcgJgA03RbY= X-Received: by 2002:adf:dd50:: with SMTP id u16mr42623916wrm.380.1619683439016; Thu, 29 Apr 2021 01:03:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuQnzH7+LlnvNv1KQ6IDmWoKufQpseUTeodtg+n2IDhGUZTQyY3Wf+IV7GlJMBU8uHpNc21g== X-Received: by 2002:adf:dd50:: with SMTP id u16mr42623874wrm.380.1619683438660; Thu, 29 Apr 2021 01:03:58 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6158.dip0.t-ipconnect.de. [91.12.97.88]) by smtp.gmail.com with ESMTPSA id r19sm8770567wmq.33.2021.04.29.01.03.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Apr 2021 01:03:58 -0700 (PDT) Subject: Re: [PATCH 1/6] mm/thp: Simplify copying of huge zero page pmd when fork To: Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Mike Kravetz , Mike Rapoport , Axel Rasmussen , Andrea Arcangeli , Hugh Dickins , "Kirill A . Shutemov" , Andrew Morton , Jerome Glisse References: <20210428225030.9708-1-peterx@redhat.com> <20210428225030.9708-2-peterx@redhat.com> From: David Hildenbrand Organization: Red Hat Message-ID: Date: Thu, 29 Apr 2021 10:03:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210428225030.9708-2-peterx@redhat.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 80057C0007EA X-Stat-Signature: t7ba53y4t4a9qdy77ed7a7he9awky5c6 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619683445-961570 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: On 29.04.21 00:50, Peter Xu wrote: > Huge zero page is handled in a special path in copy_huge_pmd(), however it > should share most codes with a normal thp page. Trying to share more code with > it by removing the special path. The only leftover so far is the huge zero > page refcounting (mm_get_huge_zero_page()), because that's separately done 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 too. > > 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 98456017744d6..22bf2d0fff79b 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -1076,17 +1076,13 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct 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 = mm_get_huge_zero_page(dst_mm); > - set_huge_zero_page(pgtable, dst_mm, vma, addr, dst_pmd, > - zero_page); > - ret = 0; > - goto out_unlock; > + mm_get_huge_zero_page(dst_mm); > + goto out_zero_page; > } > > src_page = pmd_page(pmd); > @@ -1110,6 +1106,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); > > AFAIKs, the only change is that we're now doing an additional pmdp_set_wrprotect(src_mm, addr, src_pmd) pmd = pmd_mkold(pmd_wrprotect(pmd)); But as we are copying the zeropage, it should already be write-protected, so no effective change. LGTM -- Thanks, David / dhildenb