Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp32414834rwd; Fri, 7 Jul 2023 13:36:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlEqviJPXAP2pqIyEznx6R6q+MdP40mHuZYFp+05E41frPlG25XYNkJJDLjTDVtdCM4Hs9TA X-Received: by 2002:a05:6e02:5c8:b0:345:d2fe:da92 with SMTP id l8-20020a056e0205c800b00345d2feda92mr220013ils.10.1688762159820; Fri, 07 Jul 2023 13:35:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688762159; cv=none; d=google.com; s=arc-20160816; b=nEeJpBoEDsv9rLqzu1NNYs0f/NUzxNCkyIZT2aNBekgZKmIUWJpEm3+mCUwXCCeSHK JAxOdTKc8NMbHq9uixHTd9P1GMWnCkcdldX9KttOO/QVlZQbr/oUuNNNuPi21QzpU2u2 rrUCguoX8Q+cPHg7AHjnSlmc0kp1ZndW0pWGxfS5KiRUgCRU+sHeCc3fCxfHRv2olbF5 fsz8hdrVUgCrXsflU+5onzS0sjx2m2mCF9NNkDiEMBKpedEYWcKU5LzCsDG0Fg2Iquup D8n34BNcYGqzSDOUqnoK/P5iQqUe2BtDs0O+bRnjSL7FWuvkmzJtNCyIo+49fT6nTv8N T8BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=jiYXPeVVhPYiIi5FqOxRE62I4iZJmKF5ifkdaBLEcDA=; fh=SRVuZ+tZwyZXdo6kQkf5WnmdUOrsZSCtmhaD5lKZx8E=; b=Y3KYdL3/eH4+vLGo7hRZQuervL2CS5ncY8x4k4J8Myj3ZDYCDNv1YOKKenUeXFvwE4 vWIfzHule222hVbEp52/4IW3oMWYICAIhsuBb2yssvAd47LVyPQgDAtv2fflROv4WjNY 5vlOJkNhyQZ78CeEEoLBd4edMZF6/k30Y2/lzxSOVEBbmssEu8dYyG3vBKv/3PKh0snm Km3TC0jvbfbAN5+ah7tp3v422y9ylgEJYeUlAWUzHcf52GG7IPwES1k9oov5YQPpsP7U zYOqLPFtS2cTpMMgHkTD2bHKyMkukuUoKcsAbwEEkA/zM5FEQRFJOZw+QTFId/ic0FwM BGWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="0aTqwR/d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k27-20020a63ff1b000000b0054ffc2d9fc3si3506670pgi.38.2023.07.07.13.35.41; Fri, 07 Jul 2023 13:35:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="0aTqwR/d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229515AbjGGUD3 (ORCPT + 99 others); Fri, 7 Jul 2023 16:03:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232454AbjGGUD1 (ORCPT ); Fri, 7 Jul 2023 16:03:27 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78B8C1FE1 for ; Fri, 7 Jul 2023 13:03:25 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-c6833e6e326so2563819276.1 for ; Fri, 07 Jul 2023 13:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688760204; x=1691352204; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=jiYXPeVVhPYiIi5FqOxRE62I4iZJmKF5ifkdaBLEcDA=; b=0aTqwR/dpi0vpYuL7RdUssVpIH0lUmB7Xo91oQVnf+ilkQDF98MAWO0vCOgJKJskml HDbMD8n4sTjxGTKqIrLBS+zpYcFfkT7M5RxXAUFaZ4RiffjjlN1JI7lYDC6Z1wUBEOyE bCstYIYNMrmLVmCEvJmDg8oJyJ4pE/rRVwfx3rgVXQIWDsf1LC+nuTul0LXi2F/5rl9F Fh2d5JBeZfwz0TT+GS7rDI07SGX5MnjlPhfVvpjOQzlp/ww+KftyoZX1hxmwuomie533 6qez7jIIBW0ZBqRpRUT/ZMWM47LVk+VMAnvg3VAlbRS46l6F//g2kgJFK6uV8Qskg84V 5zcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688760204; x=1691352204; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jiYXPeVVhPYiIi5FqOxRE62I4iZJmKF5ifkdaBLEcDA=; b=FWh1g+oMGHQQzIhSMaRMCZENdyHQaf+O2tfe6Xp8VqBiQ6T81SyB9U25MihiAlEtpX shS4SiPbnK3EUtIYjFbY886F1DFgj8tD1kv9U3A+CvxrUzLWH5iosonAgjQ7EEJK4jsy 8BbWAaR6xxemid5pii20rqtmB7yCRAmEiLeHOaIt7edQxdQgp7R2vHOWmnTxjIcTW1Mv Vhdl6R9yf2jF41RgX6QWHNUT2fofZUo84PYckspd8xr7sPLC1AoAG9xwuLt3ew28btaY daQuwX3iBIYRmSVoUqVtmahN3Yt2eTPjKYMbq6rgIJhQj/hpfUeK/7trF0v6As36z7xS z8XQ== X-Gm-Message-State: ABy/qLaTkGZmkYFfUL5epPqBIvzd4yEPrvTRirabv2riS6e3BWcZ8vo/ wU5xT5p9TND8Sa9Hs0XOg5InKOq+Op2LH+F+MKEU7g== X-Received: by 2002:a5b:44a:0:b0:c0b:7483:5cf0 with SMTP id s10-20020a5b044a000000b00c0b74835cf0mr4783782ybp.65.1688760204437; Fri, 07 Jul 2023 13:03:24 -0700 (PDT) MIME-Version: 1.0 References: <20230707043211.3682710-1-surenb@google.com> <20230707122750.f7cd77fe19b625cff37423ed@linux-foundation.org> In-Reply-To: <20230707122750.f7cd77fe19b625cff37423ed@linux-foundation.org> From: Suren Baghdasaryan Date: Fri, 7 Jul 2023 20:03:13 +0000 Message-ID: Subject: Re: [PATCH 1/2] mm: lock a vma before stack expansion To: Andrew Morton Cc: willy@infradead.org, liam.howlett@oracle.com, david@redhat.com, peterx@redhat.com, vbabka@suse.cz, michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, hannes@cmpxchg.org, dave@stgolabs.net, ldufour@linux.ibm.com, hughd@google.com, punit.agrawal@bytedance.com, lstoakes@gmail.com, rientjes@google.com, axelrasmussen@google.com, jannh@google.com, shakeelb@google.com, tatashin@google.com, gthelen@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 7, 2023 at 7:27=E2=80=AFPM Andrew Morton wrote: > > On Thu, 6 Jul 2023 21:32:10 -0700 Suren Baghdasaryan = wrote: > > > With recent changes necessitating mmap_lock to be held for write while > > expanding a stack, per-VMA locks should follow the same rules and be > > write-locked to prevent page faults into the VMA being expanded. Add > > the necessary locking. > > What are the possible runtime effects of this change? During the stack expansion concurrent page faults would have to wait and visa versa (stack expansion would have to wait if there are ongoing page faults). I think it's the same runtime effects as the recent similar change requiring mmap_lock to be write lock before stack expansion. > > > --- a/mm/mmap.c > > +++ b/mm/mmap.c > > @@ -1977,6 +1977,8 @@ static int expand_upwards(struct vm_area_struct *= vma, unsigned long address) > > return -ENOMEM; > > } > > > > + /* Lock the VMA before expanding to prevent concurrent page fault= s */ > > + vma_start_write(vma); > > /* > > * vma->vm_start/vm_end cannot change under us because the caller > > * is required to hold the mmap_lock in read mode. We need the > > @@ -2064,6 +2066,8 @@ int expand_downwards(struct vm_area_struct *vma, = unsigned long address) > > return -ENOMEM; > > } > > > > + /* Lock the VMA before expanding to prevent concurrent page fault= s */ > > + vma_start_write(vma); > > /* > > * vma->vm_start/vm_end cannot change under us because the caller > > * is required to hold the mmap_lock in read mode. We need the > > -- > > 2.41.0.255.g8b1d071c50-goog > > -- > To unsubscribe from this group and stop receiving emails from it, send an= email to kernel-team+unsubscribe@android.com. >