Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp181023rwo; Tue, 1 Aug 2023 15:11:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlGbfLM9leTWxfxDsQfnSYFFYFFd370t2J/TYD07GN081SD6XXcQDzwWQ1u945D2PGDXuqz/ X-Received: by 2002:a05:6870:40c6:b0:1b3:cb1f:cd1f with SMTP id l6-20020a05687040c600b001b3cb1fcd1fmr17601506oal.0.1690927873267; Tue, 01 Aug 2023 15:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690927873; cv=none; d=google.com; s=arc-20160816; b=DUl/D3Oig2WsyDv2ads9vEMi121cPIM5rFL6vVqzmz8H1VFOYKXC0570uE2nibOi4q WIQSEZcM+I0/mxWfDXb2ooDD3OiOp3VOfrTN3IuSZHoyS28nlIwk9SaYqNP26AL8J37Q Sjm7VkJ/ZKo6aW6xt2ZmuJJc2134NdgUxXJ+8Q0ne9GTIny5hBhW2dFpBc9z0LSeRP1P aCGnelWbMF5HyXnbU5Pu/RovHj0mG7uydKnjwOsnJeh0IEheMLtCLeuMPGPsXAQj2NK1 D/ij0iC858SJAA0hUtSUa/4/wTZu3E54hSE+Fz0cT7flOsqk9PINuQH23r8Dp76wbY3E GF5g== 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=nTaLTuEwmGPK8tN27uBTIdCdSaj9gN4+SfwrhnvaMfY=; fh=w+60nX3ZvnR7eowsAk6bkZJuudootphkquUbsDZOA7A=; b=JwRtzUMMXt0m5VVyA0I+R9nZmMPPVU9PW3NQcuWT2iw4DghPbr+7ZikWJK+gRdVNVt k7Zj9dxs2QNgQPtfCVccR30HkZ2RCE53ZBDA0kepZqkZLeBiKw4l5KHg2QBitKLLInk9 6d7NyFYrO+nba8S5wAcf5l5xHVdtLzZzBZJsKvikVp1w2PyzlrsQILaZwNmxmm233MPd 4x1XFiiZQAcEcpBs2IF/sm3Rqv1S+PhS5DitFJNuT+ubVD0kLhACnKeiR6jj5Tahrqdl f8AZdhcODK7yKOQtNdfSF5ytxfKncUGqbbeRLZVbMICp0Nqps/y2GzSsOz8uN2/W3Eor u60A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=wKkIGL5Q; 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 137-20020a63018f000000b0055c8d14df3asi9281180pgb.799.2023.08.01.15.10.59; Tue, 01 Aug 2023 15:11:13 -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=wKkIGL5Q; 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 S229985AbjHAVqn (ORCPT + 99 others); Tue, 1 Aug 2023 17:46:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232065AbjHAVql (ORCPT ); Tue, 1 Aug 2023 17:46:41 -0400 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C0681FE8 for ; Tue, 1 Aug 2023 14:46:40 -0700 (PDT) Received: by mail-yb1-xb2b.google.com with SMTP id 3f1490d57ef6-ccc462deca6so6285029276.0 for ; Tue, 01 Aug 2023 14:46:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690926399; x=1691531199; 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=nTaLTuEwmGPK8tN27uBTIdCdSaj9gN4+SfwrhnvaMfY=; b=wKkIGL5QEwxPU/tl47JEmFmOAgyw6qmj09012fom2578AWEqp81tCUj9apQdZBhtM3 DKkRxP/vTZRapL3elEErpnJTE2BYWjFHrNBtrpmWcgLn+86jjjTg1yMRA9dRErCMY0om RPOCd+sN77GTewLL9uq7DceIP0PztJ/PC9WSBwb7lRCjhtMpntlwOpDtV9h4+NHYkJzi UDY+3Bx2yEb15edjfKNCXAjlzx1RtuBzcHespcqZqRSGNnKSBWNfbxZDFS1tyO3dusSd Jc4fqBzfD1oqOeso7ifAeM0e+PoR7x4iP+zAU+ZVx+T3nzRclFxn2j36jlXx4+30EoFM 6log== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690926399; x=1691531199; 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=nTaLTuEwmGPK8tN27uBTIdCdSaj9gN4+SfwrhnvaMfY=; b=J9OI9nwlK+j1k8FIjgJats0BLUef0UjuB+qyUC3Fc3Io7RhlVBimzllVgpRJCxrSAv 1PRwtO0tS3CEFUuHbDcJyV+HiM2aaoSrMaON5G6VfNrB84bShCgpbJiwtKqTCValX5Yk XJm2RRa5BtQ1fxLpb+DI+mrt8biZujHZs/1FhxXWcE/ycmT6HeTyShGght6SW9EIhtaM ZDPf93NaP74lFSOsaDbbBV1Xe3G317Htg/G/NRjc+jniJFKmROHfDLeXpt2Mz8irovHv vZXywTk5tYRj4Fd+m6pgSblRzOZ5qA2Upx1jDBs0SRy2u1UBXVBOX76igkMKGxTQiOzQ lr/g== X-Gm-Message-State: ABy/qLYLe0paF3QGPMWzXRJEju9RXoKBY9bV+DQWaZbyZ9vCaoN3akp0 qAwbbYcMMkRhhmelcECvNG+s8v3uVaksskJcBfUGrw== X-Received: by 2002:a25:cbd2:0:b0:d0d:baae:93 with SMTP id b201-20020a25cbd2000000b00d0dbaae0093mr16326018ybg.39.1690926399468; Tue, 01 Aug 2023 14:46:39 -0700 (PDT) MIME-Version: 1.0 References: <20230731171233.1098105-1-surenb@google.com> <20230731171233.1098105-2-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Tue, 1 Aug 2023 14:46:25 -0700 Message-ID: Subject: Re: [PATCH 1/6] mm: enable page walking API to lock vmas during the walk To: Peter Xu Cc: Linus Torvalds , akpm@linux-foundation.org, jannh@google.com, willy@infradead.org, liam.howlett@oracle.com, david@redhat.com, ldufour@linux.ibm.com, vbabka@suse.cz, michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, hannes@cmpxchg.org, dave@stgolabs.net, hughd@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org 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_BLOCKED,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 Tue, Aug 1, 2023 at 2:34=E2=80=AFPM Peter Xu wrote: > > On Tue, Aug 01, 2023 at 01:28:56PM -0700, Suren Baghdasaryan wrote: > > I have the new patchset ready but I see 3 places where we walk the > > pages after mmap_write_lock() while *I think* we can tolerate > > concurrent page faults (don't need to lock the vmas): > > > > s390_enable_sie() > > break_ksm() > > clear_refs_write() > > This one doesn't look right to be listed - tlb flushing is postponed afte= r > pgtable lock released, so I assume the same issue can happen like fork(): > where we can have race coditions to corrupt data if, e.g., thread A > writting with a writable (unflushed) tlb, alongside with thread B CoWing. Ah, good point. > > It'll indeed be nice to know whether break_ksm() can avoid that lock_vma > parameter across quite a few function jumps. I don't yet see an immediate > issue with this one.. No idea on s390_enable_sie(), but to make it simpl= e > and safe I'd simply leave it with the write vma lock to match the mmap > write lock. Thanks for taking a look, Peter! Ok, let me keep all three of them with vma locking in place to be safe and will post v2 for further discussion. Thanks, Suren. > > Thanks, > > -- > Peter Xu >