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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 2C09DC433DB for ; Tue, 9 Feb 2021 17:13:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5690B64EC0 for ; Tue, 9 Feb 2021 17:13:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5690B64EC0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9786A6B0005; Tue, 9 Feb 2021 12:12:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 928F26B006C; Tue, 9 Feb 2021 12:12:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83D496B006E; Tue, 9 Feb 2021 12:12:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id 6E91B6B0005 for ; Tue, 9 Feb 2021 12:12:59 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 37BDB185072EA for ; Tue, 9 Feb 2021 17:12:59 +0000 (UTC) X-FDA: 77799374478.29.men35_53011da27609 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id B8A841844C6CD for ; Tue, 9 Feb 2021 17:08:27 +0000 (UTC) X-HE-Tag: men35_53011da27609 X-Filterd-Recvd-Size: 4351 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Feb 2021 17:08:27 +0000 (UTC) Received: by mail-qt1-f172.google.com with SMTP id b24so3703227qtp.13 for ; Tue, 09 Feb 2021 09:08:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Qp51bJAnCxRzPtY1o+jY/3jp3n/9goiRJUkRixlc70o=; b=kD2Bfhua6VvOK6iytfykuRQDM/0R9wRTUCOxf3mJKv+hakWzIu/ioukguX2dXmLzwC bs3Uo3XPShrcDjyaKg5ivKB1IZ5pNbRbKr73nv51RJ+sX2t9e3mW1RaweilvgE7f5gAE hYFjgvs3586YP8fcOkiYrMmeaHpuGFvDO5noKp0ccxMwnCX/idC+2YTKEoUXYgf5O01b NAGLTLkua4doxk3ESkHz87UHCgGdxjMOGITRsC1wzBMc72w2g2IIQ0X4V8Zq6wDfFFU+ vO06K8/vqqEiKuoo9FgQt/mMC2OI1T7vDE+pNTVM7qVKETTFb3Yaa5Ap++/z6+fER6Fi lbKg== 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=Qp51bJAnCxRzPtY1o+jY/3jp3n/9goiRJUkRixlc70o=; b=SwvxfvmzTNN9qRmkwECv09ww9DYl1PiOisXVMeL9l+CaU0wrur0uCpTWtbgkDUsD3Z dLfjyTAEichvWES7+Z12QgBj33iXov/pzwdCU1yLa+5kdP5vH+syDDqpAF4IwShPOWUR 9yl9ih//pfgNvm6HZFhR3Oydt2uOpRBzgoy1WT4+Lki37QLzVi38gbEWBHdJuzEHD+mM sTgX222CNJ/lgh25NNrFRIPsBmEuXPewTX3fsjIsYPdbuu9U1hCufQ17pPWaaKV+ooiK hzG6XS51IZacwo//tsurO8IdNxqvn38SHsoIFfzpQcQ9N9g80+0ld369Wz5lqvAQLKy9 qf8w== X-Gm-Message-State: AOAM530X3ytnFEp+UBS6KPnoF+lDID6zK4wO/St908n92AD1ezy+wnhv 6pFyycRu3qQEl/dgELQgtn3xpw== X-Google-Smtp-Source: ABdhPJy+jJZQyKh8MsZQ5/WymDZftiAca2R0LvpLq9o5UwlDiV9X2ZSf3KpjMrxz7NmjL+BLQHEDlw== X-Received: by 2002:ac8:2231:: with SMTP id o46mr17889981qto.245.1612890506671; Tue, 09 Feb 2021 09:08:26 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-115-133.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.115.133]) by smtp.gmail.com with ESMTPSA id q15sm5938378qti.9.2021.02.09.09.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 09:08:25 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1l9WUz-005VF2-3m; Tue, 09 Feb 2021 13:08:25 -0400 Date: Tue, 9 Feb 2021 13:08:25 -0400 From: Jason Gunthorpe To: Matthew Wilcox Cc: linux-mm@kvack.org, "Liam R. Howlett" , Laurent Dufour , Paul McKenney Subject: Re: synchronize_rcu in munmap? Message-ID: <20210209170825.GG4718@ziepe.ca> References: <20210208132643.GP308988@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210208132643.GP308988@casper.infradead.org> 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 Mon, Feb 08, 2021 at 01:26:43PM +0000, Matthew Wilcox wrote: > TLDR: I think we're going to need to call synchronize_rcu() in munmap(), > and I know this can be quite expensive. Is this a reasonable price to > pay for avoiding taking the mmap_sem for page faults? In my experience we have been ripping out synchronize_rcu() in places that intersect with userspace, it can be very slow and if something does more than one iteration things get bad. Based on that mmunmap seems like a poor place to put synchronize_rcu() > Next problem: /proc/$pid/smaps calls walk_page_vma() which starts out by > saying: > mmap_assert_locked(walk.mm); > which made me realise that smaps is also going to walk the page > tables. Aren't the presense/absence of the page table levels themselves managed under the page table locks? I thought that unused levels were wiped in some lazy fasion after the TLB flush based on being empty? There is a state graph of allowed page entry transitions under the read side of the mmap sem, and allocated -> freed table is not allowed (freed -> allocated is OK though, IIRC). I think this has nothing to do with the mmap_sem acting as a VMA lock, it feels like some extra behavior. Jason