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=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 DC5D5C83004 for ; Tue, 28 Apr 2020 06:11:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 986E1206D7 for ; Tue, 28 Apr 2020 06:11:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cdP0uVyD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 986E1206D7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4FA248E0006; Tue, 28 Apr 2020 02:11:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AAED8E0001; Tue, 28 Apr 2020 02:11:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C1198E0006; Tue, 28 Apr 2020 02:11:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id 210028E0001 for ; Tue, 28 Apr 2020 02:11:22 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id AAD6F180AD804 for ; Tue, 28 Apr 2020 06:11:21 +0000 (UTC) X-FDA: 76756241562.06.heat91_28ecd894e3301 X-HE-Tag: heat91_28ecd894e3301 X-Filterd-Recvd-Size: 4877 Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 28 Apr 2020 06:11:20 +0000 (UTC) Received: by mail-lf1-f68.google.com with SMTP id f8so15889773lfe.12 for ; Mon, 27 Apr 2020 23:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fjR2WXsg1WuSqX8WD5c+nhnalPJJVRAV+Xn9CSGG1bY=; b=cdP0uVyDLEuTHWB46kef943mTKZiv/Grb+3pidmYUxbnYjhqmBibE45csv9aQ88lot AJ3IDfIwUFyKZ0ltlC/7Xz/eIBrBQ9fKuiYosWuO9jxHiT7plltOgrcHcyVpxe7QmbFJ +/ZAj1QUE0+7MbjnRNVVxQdmpxWa3++ZAydGa9ZaoAwMf5FQMxsgbkOQjpNYPiBk1sY+ 4yiGOkjuYSnheFG1MggDO6unAQSkGnM4raGCF4V8kQa2tBeFbthnB+CXJOmDktWBOEtl eTb5TN7/Nnq4dr6LqUU6zAA7IbwWt3mzS4YUp1+NK/1MBrYrdLqkTHc4pCWe0R/ARh+9 +0pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fjR2WXsg1WuSqX8WD5c+nhnalPJJVRAV+Xn9CSGG1bY=; b=gXfgBjV+0J9l9kKFX+LfK13QrulEtOp+4G+fbuR6TC7FfzigY/ii7sPt1Z4qZ6FoJs f35oyrGxj5CIt9uuMMfbQ20hAnMUYsSWhdd3lXLO8Mk5mZTq4XJm6PpNaY5JJ1moeArv 3ifuNIzar0xszEPtDPGj+8Z94Boefr/RTMKMFokTTfUeo204gOL8yxBGfxHyUF48IqE+ UAEaBpVpRwhuSUVoSk3HKvzxM19VOJkz1Ua8af/+u0XVKkeyFqt6bv2Fw0bdzZzjhr32 dJZbK/H6lBFKqttktDtV6h/6xQeu51E1AAHOUbOMIDveoTn6J6qyZ4/XR7yRYsz3laXS 38Qw== X-Gm-Message-State: AGi0Pua+nfDCliQGriaErI9MzHUGGJnMsm/mwf1kfWup+BF7dXjSAZW8 UpNlYxFPZ/WzqFl3FoKCAc/d+m3F0ibZhRk0kQzwbg== X-Google-Smtp-Source: APiQypLIie/TYTkh1e9E9TFpjYomoyBZT+NMzXY2V+G8zBhTAdtjDWAqu5o9w5HGdoenyRP931MOYycHK/t36nWbs+Q= X-Received: by 2002:a19:e04a:: with SMTP id g10mr17744131lfj.164.1588054277719; Mon, 27 Apr 2020 23:11:17 -0700 (PDT) MIME-Version: 1.0 References: <20200428032745.133556-1-jannh@google.com> <20200428032745.133556-6-jannh@google.com> In-Reply-To: From: Jann Horn Date: Tue, 28 Apr 2020 08:10:51 +0200 Message-ID: Subject: Re: [PATCH 5/5] mm/gup: Take mmap_sem in get_dump_page() To: Linus Torvalds Cc: Andrew Morton , Christoph Hellwig , Linux Kernel Mailing List , Linux-MM , linux-fsdevel , Alexander Viro , "Eric W . Biederman" , Oleg Nesterov , Russell King , Linux ARM , Mark Salter , Aurelien Jacquiot , linux-c6x-dev@linux-c6x.org, Yoshinori Sato , Rich Felker , Linux-sh list Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000082, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Apr 28, 2020 at 5:50 AM Linus Torvalds wrote: > On Mon, Apr 27, 2020 at 8:28 PM Jann Horn wrote: > > > > Properly take the mmap_sem before calling into the GUP code from > > get_dump_page(); and play nice, allowing __get_user_pages_locked() to drop > > the mmap_sem if it has to sleep. > > This makes my skin crawl. > > The only reason for this all is that page cache flushing. > > My gut feeling is that it should be done by get_user_pages() anyway, > since all the other users presumably want it to be coherent in the > cache. > > And in fact, looking at __get_user_pages(), it already does that > > if (pages) { > pages[i] = page; > flush_anon_page(vma, page, start); > flush_dcache_page(page); > ctx.page_mask = 0; > } > > and I think that the get_dump_page() logic is unnecessary to begin with. Ah! And even though flush_cache_page() is broader than flush_dcache_page(), that's actually unnecessary, right? Since the kernel only wants to read from the page, and therefore e.g. the icache is irrelevant? Yay! :) I did think this was a bit gnarly, and it's nice to know that this can be simplified. (And now I'm going to avert my eyes from the GUP code before I start thinking too hard about how much it sucks that FOLL_LONGTERM doesn't drop the mmap_sem across the access and how much I dislike the whole idea of FOLL_LONGTERM in general...)