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=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 4B1FDC433DB for ; Fri, 5 Feb 2021 16:05:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C1A8364F2E for ; Fri, 5 Feb 2021 16:05:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1A8364F2E 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 39D406B0071; Fri, 5 Feb 2021 11:05:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 34D476B007B; Fri, 5 Feb 2021 11:05:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23CAA6B007E; Fri, 5 Feb 2021 11:05:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0172.hostedemail.com [216.40.44.172]) by kanga.kvack.org (Postfix) with ESMTP id 09C996B0071 for ; Fri, 5 Feb 2021 11:05:41 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id CBAB92497 for ; Fri, 5 Feb 2021 16:05:40 +0000 (UTC) X-FDA: 77784689640.25.C3220CA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 7D372C0042D1 for ; Fri, 5 Feb 2021 16:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612541136; 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: in-reply-to:in-reply-to:references:references; bh=JoM62AWSDevjens3EGjD01RZCxIT1WEOEpSFlKtGj24=; b=LRuVO87+Kc1lA/BU0ajvAADS2IcwN17ZVvQ2gfUSkJaZIG26tnSUXEg+7jTDmy3Ijxbd+x +aqR4xN7Z3Xv62eDzf7PwBcdaqdZblrkGmE2VbCYEM9MGumy40SxsVz6mgTnAIXFUb2yv7 90toUo/UufZdOcTgEftP2JF5kjQy1FQ= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-433-rmoLxzSeNwGqV_t6OLyj5Q-1; Fri, 05 Feb 2021 11:05:33 -0500 X-MC-Unique: rmoLxzSeNwGqV_t6OLyj5Q-1 Received: by mail-qk1-f197.google.com with SMTP id j78so6213215qke.11 for ; Fri, 05 Feb 2021 08:05:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JoM62AWSDevjens3EGjD01RZCxIT1WEOEpSFlKtGj24=; b=eqFNXJnOBR69I23VRZWkNh5Z05BErkA+JqAU8fS3JajfZv9M5bUIION733AffiCP89 RGOCUoD7iBHSpCPaz6mgkPvRJJ4TWDm2zrgr7j1bawE50ZNyrtkeCxRqy7JoSvaTFMIq NkFaZXpWGODX3X0X3+ZnovNmNaI1938z/ChC2CZSSacprH43sdCavmlzmGcewAgW/0La 7S0q4bbcPzpr8jlmw6vEQ5LGGiI9GRjLXog+iDrftwjoqHgovnVva867hh7H4ONhn38o xEangnBLhevd+bfzwl3eq/ySZQebToLRsGotvAybG1ryNulMXR9DB63FCrnPWjEaHxsA qq9w== X-Gm-Message-State: AOAM532gLKw26vVwOv17hadqmkrTNfGkkhPgp+1kH3jk+p5zoYuYFSfQ FH786OU5ROltFj2MZnNmhGBi+7GQUgD/I0qhrFaDiKXZgpeBUfAlSE7i/YuxdKzNRk9COIyLnrB im3B1i5cXUvE= X-Received: by 2002:a37:b346:: with SMTP id c67mr5077309qkf.212.1612541132730; Fri, 05 Feb 2021 08:05:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQM80RYsZTBhWjWiOiR1RHPvEgAzVUDDgbkzNLvCUyrFrGIeU8bK80LifWphXArYXXlDyxcA== X-Received: by 2002:a37:b346:: with SMTP id c67mr5077289qkf.212.1612541132526; Fri, 05 Feb 2021 08:05:32 -0800 (PST) Received: from xz-x1 (bras-vprn-toroon474qw-lp130-20-174-93-89-182.dsl.bell.ca. [174.93.89.182]) by smtp.gmail.com with ESMTPSA id o10sm8653688qtg.37.2021.02.05.08.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 08:05:31 -0800 (PST) Date: Fri, 5 Feb 2021 11:05:30 -0500 From: Peter Xu To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Kirill Shutemov , Wei Zhang , Mike Rapoport , Matthew Wilcox , Miaohe Lin , Andrea Arcangeli , Gal Pressman , Jan Kara , Jann Horn , Andrew Morton , Kirill Tkhai , Linus Torvalds , Jason Gunthorpe , David Gibson , Christoph Hellwig Subject: Re: [PATCH v2 4/4] hugetlb: Do early cow when page pinned on src mm Message-ID: <20210205160530.GZ6468@xz-x1> References: <20210204145033.136755-1-peterx@redhat.com> <20210204145033.136755-5-peterx@redhat.com> <20210205014328.GW6468@xz-x1> <4344397d-cf08-b502-d5ff-76f19e778dfe@oracle.com> MIME-Version: 1.0 In-Reply-To: <4344397d-cf08-b502-d5ff-76f19e778dfe@oracle.com> 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=utf-8 Content-Disposition: inline X-Stat-Signature: 85po57jsbgmb4g497zck7xiwqrn9wpsi X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 7D372C0042D1 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=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1612541137-789745 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Feb 04, 2021 at 09:11:24PM -0800, Mike Kravetz wrote: [...] > >>> @@ -3787,7 +3803,7 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, > >>> dst_entry = huge_ptep_get(dst_pte); > >>> if ((dst_pte == src_pte) || !huge_pte_none(dst_entry)) > >>> continue; > >>> - > >>> +again: > >>> dst_ptl = huge_pte_lock(h, dst, dst_pte); > >>> src_ptl = huge_pte_lockptr(h, src, src_pte); > >>> spin_lock_nested(src_ptl, SINGLE_DEPTH_NESTING); > > > > Side question: Mike, do you know why we need this lock_nested()? Could the src > > lock be taken due to any reason already? It confused me when I read the chunk. > > I see that it was added with commit 4647875819aa. That was when huge pages > used the single per-mm ptl. Lockdep seemed to complain about taking > &mm->page_table_lock twice. Certainly, source and destination mm can not > be the same. Right? Right, at least that's my understanding.. > I do not have the full history, but it 'looks' like > lockdep might have been confused and this was added to keep it quiet. > > BTW - Copy page range for 'normal' pages has the same spin_lock_nested(). Yes. I'll need to take the same lock in v3, so I think I'll just follow. Thanks, -- Peter Xu