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=-6.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 677A5C43460 for ; Wed, 28 Apr 2021 15:14:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ED5B761434 for ; Wed, 28 Apr 2021 15:14:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED5B761434 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 61D976B0036; Wed, 28 Apr 2021 11:14:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F50C6B0071; Wed, 28 Apr 2021 11:14:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E3246B0072; Wed, 28 Apr 2021 11:14:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0116.hostedemail.com [216.40.44.116]) by kanga.kvack.org (Postfix) with ESMTP id 3099A6B0036 for ; Wed, 28 Apr 2021 11:14:09 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D8DD23653 for ; Wed, 28 Apr 2021 15:14:08 +0000 (UTC) X-FDA: 78082121376.08.1D1FD3E Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf17.hostedemail.com (Postfix) with ESMTP id A8EF640002E6 for ; Wed, 28 Apr 2021 15:14:04 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 60CC361447 for ; Wed, 28 Apr 2021 15:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619622847; bh=xG7IdJumg4Q9sXJ8+UBUVHjJ+hKMOn7nNzLC0QXPCQU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ksjBkX+Sw4ROm+ksLudw+FDw/+NmY/ywobwWShXfUoBKOOYoAcZR2+k4PZK/f1Xud nvBWDWpDKansHO99Hqz82+rPuGcPJ1gqhWPSAF/EQIUJCU7Wg1G04iFLXW/ZhwdoHZ TrrnV7pFmK2E4W1HDN3JLm+6BvfRmIYJsV/bn4P0MuS+yMc2Xv2ejwz8JlkxzWDvDa wteZ1ICPuRFSz3H+ztxiuhouJLagQoE+mN8K9zxESNDOJIvgfJ/x44AdqCB07sUNKt M2fKPJJS5OkqVbWSpedvwVcoD6DPf9z2Rs/WkiOVH/7U7TgYyZFoBpCIp8EvN3wCbn 4dRUo6q8EyTcA== Received: by mail-ej1-f53.google.com with SMTP id r9so95187637ejj.3 for ; Wed, 28 Apr 2021 08:14:07 -0700 (PDT) X-Gm-Message-State: AOAM531kdw0yR2Rq3arkRyCMt3qwixTmy8VLhQRD8FKVM4X2BZ9ouYbN fttxZ//3zKARkdcGscQk8kKvRr/dzM0FxNZ8Mf5sNg== X-Google-Smtp-Source: ABdhPJxOcmIc+lDu0PisdMd/DERFJX0tTTN+bEnjlJAW1lkwYOMUPs398lWAWCP3CiFZM6LmCf3D166ugEX/ePVWSjw= X-Received: by 2002:a17:906:f742:: with SMTP id jp2mr13124583ejb.199.1619622845689; Wed, 28 Apr 2021 08:14:05 -0700 (PDT) MIME-Version: 1.0 References: <20210407014502.24091-1-michel@lespinasse.org> <20210407014502.24091-14-michel@lespinasse.org> <20210428145823.GA856@lespinasse.org> In-Reply-To: <20210428145823.GA856@lespinasse.org> From: Andy Lutomirski Date: Wed, 28 Apr 2021 08:13:53 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 13/37] mm: implement speculative handling in __handle_mm_fault(). To: Michel Lespinasse Cc: Andy Lutomirski , Paul McKenney , Linux-MM , Laurent Dufour , Peter Zijlstra , Michal Hocko , Matthew Wilcox , Rik van Riel , Andrew Morton , Suren Baghdasaryan , Joel Fernandes , Rom Lemarchand , Linux-Kernel Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: xqhmjugcp3s9ijkbi98d33iusyq157ng X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: A8EF640002E6 Received-SPF: none (kernel.org>: No applicable sender policy available) receiver=imf17; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619622844-56740 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 Wed, Apr 28, 2021 at 8:05 AM Michel Lespinasse wrote: > > On Wed, Apr 07, 2021 at 08:36:01AM -0700, Andy Lutomirski wrote: > > On 4/6/21 6:44 PM, Michel Lespinasse wrote: > > > The page table tree is walked with local irqs disabled, which prevents > > > page table reclamation (similarly to what fast GUP does). The logic is > > > otherwise similar to the non-speculative path, but with additional > > > restrictions: in the speculative path, we do not handle huge pages or > > > wiring new pages tables. > > > > Not on most architectures. Quoting the actual comment in mm/gup.c: > > > > > * Before activating this code, please be aware that the following assumptions > > > * are currently made: > > > * > > > * *) Either MMU_GATHER_RCU_TABLE_FREE is enabled, and tlb_remove_table() is used to > > > * free pages containing page tables or TLB flushing requires IPI broadcast. > > > > On MMU_GATHER_RCU_TABLE_FREE architectures, you cannot make the > > assumption that it is safe to dereference a pointer in a page table just > > because irqs are off. You need RCU protection, too. > > > > You have the same error in the cover letter. > > Hi Andy, > > Thanks for your comment. At first I thought did not matter, because we > only enable ARCH_SUPPORTS_SPECULATIVE_PAGE_FAULT on selected > architectures, and I thought MMU_GATHER_RCU_TABLE_FREE is not set on > these. But I was wrong - MMU_GATHER_RCU_TABLE_FREE is enabled on X86 > with paravirt. So I took another look at fast GUP to make sure I > actually understand it. > > This brings a question about lockless_pages_from_mm() - I see it > disabling interrupts, which it explains is necessary for disabling THP > splitting IPIs, but I do not see it taking an RCU read lock as would > be necessary for preventing paga table freeing on > MMU_GATHER_RCU_TABLE_FREE configs. I figure local_irq_save() > indirectly takes an rcu read lock somehow ? I think this is something > I should also mention in my explanation, and I have not seen a good > description of this on the fast GUP side... Sounds like a bug! That being said, based on my extremely limited understanding of how the common RCU modes work, local_irq_save() probably implies an RCU lock in at least some cases. Hi Paul! --Andy