Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19508695rwd; Wed, 28 Jun 2023 10:10:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6orDpLTgsRj8L0OKd0m8gykrJfP3rB8Mk+2gY3RSJzTwu9C4JUtvrYRM3R+lPpT5EoPhPw X-Received: by 2002:a17:902:d4d2:b0:1b8:adc:7c3d with SMTP id o18-20020a170902d4d200b001b80adc7c3dmr8037466plg.40.1687972238003; Wed, 28 Jun 2023 10:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687972237; cv=none; d=google.com; s=arc-20160816; b=dY07r46xk8d1Zpsivb5o2/+LyROt4rqRozr2/c6V97UtYZn/JdcAemZWOT0x9R3C95 uKQH4+ewMyb/vQYaHGvQtVo1iUf2x6RSlhxHVddTqNwqmz5tO/nad/eY7+GmV9/H0YfG qzh/cGBO4AoUSRIJ64XUvu2oodRbDKNfmOQ6WwjTWLksMis2KkEIE0zYlpHXB/9eDnIY wjpclkX7EmRHKg+Hw0jngJugTYjFAX/VUaSjfFfGA7KuX0NjNi5U03VNAwR5D0IKw9bs T8SrbrVhboN9bkXPI4k5U2wfTcuJZ5aaI55bNuFVuarizX41fDdpLPE8iqk5J9usK3E2 18IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rP7oTLZXnrKdM7Uf6r5o7yLX5pLrMAahCaLybcdGA/I=; fh=3DtDjy+qm2mKxT4PhD9WTKRbZFmgjURJ5LyxQ0kcJ64=; b=V4TM8spMHu/JN2GNhv6jaqJA5olNT523km0Zc4tAocLSz+xHBaLWH6vcdwlglUyb+f nJ9JgiV8GLS9XDou6IOKXLmFLQlSaYIOA7mxxfzP/eVDUHCVPssoDmv+A6PsiRBkF9w6 R//Nv/gEGJyshk28CTH/HLtJIESrdvOJB9djcviUkbLYxlbHF4aHAb+X5i0GYrGVPray uyFlQVcOTIUihkNYR5rjqEOgTIy0rEV1A/9niDBBDGY04VOaov8T4j4vHLBlW7+di1kQ umw0pOhvMS7u/aJwW0FJ+u7g1cYn0V1glz16MVWQrdAPUIH3AmFounNy+5U6BfESNj3x HROA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="f/1jFSv4"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n10-20020a1709026a8a00b001b11168bdddsi6047545plk.520.2023.06.28.10.10.25; Wed, 28 Jun 2023 10:10:37 -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=@redhat.com header.s=mimecast20190719 header.b="f/1jFSv4"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230446AbjF1Qsd (ORCPT + 99 others); Wed, 28 Jun 2023 12:48:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21031 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230216AbjF1QsI (ORCPT ); Wed, 28 Jun 2023 12:48:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687970838; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rP7oTLZXnrKdM7Uf6r5o7yLX5pLrMAahCaLybcdGA/I=; b=f/1jFSv4LLBfLYgEvAuuHpIbrQYHtljisTgKE5ffm88VuupeffqcxrTKPIyhrrhh38IHb1 cn5hquMo/MJVjC6eYmq5FgIBlk1w402UJ1CIoAacF6eT75nOJmTmP/bSGCCJLRiji8IiqV DmdhwHVuBoNEQ19w77c/G2uYiMu+0kY= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-N59JoN2ZOkCHjKHfpVoEQA-1; Wed, 28 Jun 2023 12:47:16 -0400 X-MC-Unique: N59JoN2ZOkCHjKHfpVoEQA-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-4009ad15222so86751cf.1 for ; Wed, 28 Jun 2023 09:47:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687970836; x=1690562836; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rP7oTLZXnrKdM7Uf6r5o7yLX5pLrMAahCaLybcdGA/I=; b=B/06VXmoBsk1uqmVIjpt+40ECqrZ5uHoBsVLtip/6obiLVv1Pf/cOB8pKAMncDTYxF Ni4leeQyxGRcdakdV0Fj2B/cvcEumrrFhSjlMpxxKtnZ1aFRAp5+EZ6PLJDw20okh5PG qY8qkzk+TfwcQet4g2KtXWkhno1tiJCmRa5ChZmp6UF1PnDVFii3/eTBLpYu2E9DaXn5 HT9V6u8V2y8prdgpR7KN+zcDg+PACzzpk5UCzEvDrE7P/H9wtm5S7j0BEPy2gmph5uWC z5LNhAkfBaB4JSOyk8Cev0EhFaGXgNLflhqm9MPpcLuYrz948Tln5pgoaF9J9Sl66ruo PY4A== X-Gm-Message-State: AC+VfDy048jPXwbvtbc7WcCwpuTs+yFMuPJddWNBSVWSje0XWiuM1g1c ZPN9GG/+ajGA8UoOnqQwj6RGKvm4kwRrq9fQbf1s3ly7Mu9QzikYpB4KKKXnXxN61/xz5HwpmH5 gerYzTiKIccOPolOumxD1D3OW X-Received: by 2002:a05:622a:1827:b0:400:a9a4:8517 with SMTP id t39-20020a05622a182700b00400a9a48517mr11519359qtc.4.1687970835960; Wed, 28 Jun 2023 09:47:15 -0700 (PDT) X-Received: by 2002:a05:622a:1827:b0:400:a9a4:8517 with SMTP id t39-20020a05622a182700b00400a9a48517mr11519338qtc.4.1687970835728; Wed, 28 Jun 2023 09:47:15 -0700 (PDT) Received: from x1n (cpe5c7695f3aee0-cm5c7695f3aede.cpe.net.cable.rogers.com. [99.254.144.39]) by smtp.gmail.com with ESMTPSA id r15-20020ac85e8f000000b00403214e8862sm1027423qtx.33.2023.06.28.09.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 09:47:15 -0700 (PDT) Date: Wed, 28 Jun 2023 12:47:13 -0400 From: Peter Xu To: Suren Baghdasaryan 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 Subject: Re: [PATCH v4 6/6] mm: handle userfaults under VMA lock Message-ID: References: <20230628071800.544800-1-surenb@google.com> <20230628071800.544800-7-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 28, 2023 at 09:22:24AM -0700, Suren Baghdasaryan wrote: > Ack. I was not sure if the ctx->mm would always be the same as vmf->mm. Feel free to look at the entrance of handle_userfault(), where there's: struct vm_area_struct *vma = vmf->vma; struct mm_struct *mm = vma->vm_mm; struct userfaultfd_ctx *ctx; ... ctx = vma->vm_userfaultfd_ctx.ctx; ... BUG_ON(ctx->mm != mm); ... So I think we should be safe. Thanks, -- Peter Xu