Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2695646rwd; Fri, 9 Jun 2023 15:38:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5PTsenqXN7K2xScDvBux11Vd2c9L1HZrRerXOHDuEU4uyi2OplB/hI9Y3gQip4lkK5YKh4 X-Received: by 2002:a17:90a:ead0:b0:259:c4b3:880a with SMTP id ev16-20020a17090aead000b00259c4b3880amr2567923pjb.31.1686350282950; Fri, 09 Jun 2023 15:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686350282; cv=none; d=google.com; s=arc-20160816; b=Ux15vWsxISwpY3Ejxz9Rb9LLX79PLYEok/6RGv3t+AZxjS9C/MKBwRE67n4GiB4qXF ptIXpioyzRsjZ0RPA7s6dBESW/0To4TsGqC8pIQaBLE3Ec4yJIr1ZyizSrHXnRe+9vg9 O10KIqd8v0xA5MYVt4yJSSyQBR6jrlEhlkxg43oQAOwgcI7xwcafWEelYxJqrzo5CISr xmiyP4eNQVmr/v2G/J+GiT/6RM0kPJCBg/CnFjkVpT3Z8IjP+KwYQpA/1dP6ndLTh9zG ta3V8esYJHKB6c1CHXAwE4vUHjKq+BfDVIfetG8t0vhJYQPqztrCh1uv2sVBwNz4bzV0 CREg== 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=+zT6sV+fvzmgBBI81QXgaF+Btrnt6GH7aWTnX6MCUB4=; b=IroXwxbozlZTjKfHJqkHmARdhXssKdsFzv80tsqAqEkyDR7fkKliRU8Y35Ex93FCbN B8DD7VGcA+fCHz42MuLLDrItOBHKbRvkTGPFdqttCN6t9rX4J6vVsTU5zwv1lkCdqkjF x4L3cVzMaqrSVn61LJiudGr88eqDppRG2NVMoYa8Gvk/wc7ux/0DsW0ndsz0L5WZWgYs Kl1Nl19RF7FfTLLlMkeyvCVtaeCA1WVJEeRBTqah55YyhCCY1+kecNyV4oA/1i583naU 9SgRMmewJR7uXvj2UXQnYuWco0xMo6/Oswh8kMmSwg8+a4dHTbfIHFUzNMMCejVcTTOf hf2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=mXAcURqk; 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 mg20-20020a17090b371400b00256a6aab74esi4978857pjb.111.2023.06.09.15.37.37; Fri, 09 Jun 2023 15:38:02 -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=mXAcURqk; 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 S231630AbjFIWaZ (ORCPT + 99 others); Fri, 9 Jun 2023 18:30:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229831AbjFIWaY (ORCPT ); Fri, 9 Jun 2023 18:30:24 -0400 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0177B359D for ; Fri, 9 Jun 2023 15:30:22 -0700 (PDT) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-568af2f6454so21145727b3.1 for ; Fri, 09 Jun 2023 15:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686349822; x=1688941822; 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=+zT6sV+fvzmgBBI81QXgaF+Btrnt6GH7aWTnX6MCUB4=; b=mXAcURqk+1SjmifAbWS+rzdBg3sJG/XNRZ8y8ysR8INkOv4gWnF+xs+y+SYfhtf6N/ RUzqMQwHktqLGXnFqUtsvhF5L9vLpFUwvm2N9epG17Y0Vp2wpI7ZrzX8JDonWRmiow43 mX+mucGCdEZRZwBSCuNbliPjS+zKIFFWb9/ic7yJM7pykYyKn+2kH4loCcZKtPEoA1iE lVZoLXJDhsiAM0IcrGBlFgWLUzxo4jWTIDQDnDuTB/9r0dEv+ey0PgmSn+GZP+iXEtW9 SOuHwnTb87WF5tfCuyWfCUydVDBd/5vbNI4gxJKZAzwgeQAoWA573b3Zpk+zJz2L5oom Ryow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686349822; x=1688941822; 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=+zT6sV+fvzmgBBI81QXgaF+Btrnt6GH7aWTnX6MCUB4=; b=aymm8mDmMqPjTQ0uIWjuFy3QpZSo/p3uzfyivI17m/iG7qme8yCUUZd9lVF/ACfFd/ AkKjxfh2+IaLJL+vHiGJ+bNKQC2UTXJZi/7KiwowldTW96jWQzMZ+3FNDaZ+Zmlu+S2O SXyOvZRnORCgvZB1idu7vosO4GctzFah+Bfsfpv2mz4tKzU4JdioA+2dbOtRN3plwXtw NdwcY2Vs6O0xXKFR8oND5hRNhjMlEpHq0L84YR+sZZUNnTL1T32s0DGJrwFfz4um+Apo UrrKcytZ74jiWmWAA3JklpYSraMKmq8Gl+WBCf3dQJw6aaO1aCxADEZbvvEAqY1UCn0N ZMvA== X-Gm-Message-State: AC+VfDxaAOeBOcU9E52p2JopqF8O0jEFhOZ22qFgE/yxvu2Fog2FBGzV mnHLvRsgBErYDJXyLm7YsqyZMS8yKr/66PX92wDeOA== X-Received: by 2002:a0d:d8cb:0:b0:559:e1b2:70c6 with SMTP id a194-20020a0dd8cb000000b00559e1b270c6mr2210211ywe.34.1686349821843; Fri, 09 Jun 2023 15:30:21 -0700 (PDT) MIME-Version: 1.0 References: <20230609005158.2421285-1-surenb@google.com> <20230609005158.2421285-5-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Fri, 9 Jun 2023 15:30:10 -0700 Message-ID: Subject: Re: [PATCH v2 4/6] mm: drop VMA lock before waiting for migration To: Peter Xu Cc: akpm@linux-foundation.org, willy@infradead.org, hannes@cmpxchg.org, mhocko@suse.com, josef@toxicpanda.com, jack@suse.cz, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, michel@lespinasse.org, liam.howlett@oracle.com, jglisse@google.com, vbabka@suse.cz, minchan@google.com, dave@stgolabs.net, punit.agrawal@bytedance.com, lstoakes@gmail.com, hdanton@sina.com, apopple@nvidia.com, ying.huang@intel.com, david@redhat.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, viro@zeniv.linux.org.uk, brauner@kernel.org, pasha.tatashin@soleen.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@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=unavailable 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, Jun 9, 2023 at 1:42=E2=80=AFPM Peter Xu wrote: > > On Thu, Jun 08, 2023 at 05:51:56PM -0700, Suren Baghdasaryan wrote: > > migration_entry_wait does not need VMA lock, therefore it can be droppe= d > > before waiting. Introduce VM_FAULT_VMA_UNLOCKED to indicate that VMA > > lock was dropped while in handle_mm_fault(). > > Note that once VMA lock is dropped, the VMA reference can't be used as > > there are no guarantees it was not freed. > > Then vma lock behaves differently from mmap read lock, am I right? Can w= e > still make them match on behaviors, or there's reason not to do so? I think we could match their behavior by also dropping mmap_lock here when fault is handled under mmap_lock (!(fault->flags & FAULT_FLAG_VMA_LOCK)). I missed the fact that VM_FAULT_COMPLETED can be used to skip dropping mmap_lock in do_page_fault(), so indeed, I might be able to use VM_FAULT_COMPLETED to skip vma_end_read(vma) for per-vma locks as well instead of introducing FAULT_FLAG_VMA_LOCK. I think that was your idea of reusing existing flags? > > One reason is if they match they can reuse existing flags and there'll be > less confusing, e.g. this: > > (fault->flags & FAULT_FLAG_VMA_LOCK) && > (vm_fault_ret && (VM_FAULT_RETRY || VM_FAULT_COMPLETE)) > > can replace the new flag, iiuc. > > Thanks, > > -- > Peter Xu > > -- > To unsubscribe from this group and stop receiving emails from it, send an= email to kernel-team+unsubscribe@android.com. >