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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 8AF45C433EF for ; Wed, 8 Sep 2021 13:53:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 029686113A for ; Wed, 8 Sep 2021 13:53:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 029686113A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 414876B0072; Wed, 8 Sep 2021 09:53:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C4EE6B0073; Wed, 8 Sep 2021 09:53:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B3536B0074; Wed, 8 Sep 2021 09:53:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id 1F4426B0072 for ; Wed, 8 Sep 2021 09:53:29 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C9D642FD76 for ; Wed, 8 Sep 2021 13:53:28 +0000 (UTC) X-FDA: 78564548496.22.3035E55 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by imf12.hostedemail.com (Postfix) with ESMTP id 7358B10000AA for ; Wed, 8 Sep 2021 13:53:28 +0000 (UTC) Received: by mail-qt1-f171.google.com with SMTP id s15so1863895qta.10 for ; Wed, 08 Sep 2021 06:53:28 -0700 (PDT) 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=EDgcgZCZK6wPUyIqC9/xK51/0tzDMUPB+N6gWTIQaXE=; b=oC3gFobF/KXOztZCgVNzrkqYllEVSkqf63kKsmOXG49BfYKsb+RAPhmL80TPQ+rdFe SvnG5bRwGcHAd+/jMHiV39Qln9Q1PbETuikz+PnzalwcKWTuNreax4cOxVZE8hIyW5Nh o1yUpzgFvJBtB2zK8+SsWMnPdV2kKA94kkAw08BAYF7O0Ay0aYaiZr5dt05MKdzQQiYY Au+PrHjuvALI18M3ja2FnJfYCX4njMQ5yruciqqhZwwMP3PHAzNqBuxuGaHdr1mnTRNz GN6Y4+LT/96ZeBQ5nLKVBgNEgS/56w9Z7NDoQldA9S0zwlPAHaRvBOTyafQ2eKVbj5ub VbZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=EDgcgZCZK6wPUyIqC9/xK51/0tzDMUPB+N6gWTIQaXE=; b=vkg5+iFtocdYxTbtlAzhySyoqFdiqFDC1eYLYCuD33boV5tkMEcjBkxTppURSOHBpC dHjZ9BdTi6JF6ffLOppAcxr8T6XHVexaWKFqpNUH9vVXldrrW2zTV567fsCHFZJcJwj+ eFsDKjnw4Vrwjjq0bW+E12yS1Qz0pFaRTIbP+PJDYsOtUs8ub0XcRSCGK8EDrGVgF85F CR/U3GGgZJKgQLt+Ee1r0kkZQKiS85LOUCxQ8VluPt8HW7kvhZhF0GvoM680TPMTaAMd jF6jDK5Com6N9SUzwiHnb8K2RP+AzAsQI/vZRPa2H+jJHg2ZvgCghC4u61WR5DwpVCvI 0Vqg== X-Gm-Message-State: AOAM532ZjpyAklzvR7aT2x2sbJizP+OLWKqeaR/87599G4nsT89P1yBl niNYA7GgoP/Vca2oKNAuFCw+2g== X-Google-Smtp-Source: ABdhPJxb/RU1j6Y9l8LZ3zB9jwVoPziqRchUxN2JMaF+gjX4++L/gWm1E/TQTft6El5dUsc/ZMdZHg== X-Received: by 2002:ac8:701b:: with SMTP id x27mr3897866qtm.270.1631109207724; Wed, 08 Sep 2021 06:53:27 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id s7sm1821081qkp.18.2021.09.08.06.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 06:53:27 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1mNy10-00EWqQ-JG; Wed, 08 Sep 2021 10:53:26 -0300 Date: Wed, 8 Sep 2021 10:53:26 -0300 From: Jason Gunthorpe To: Daniel Borkmann , Peter Zijlstra , Michel Lespinasse Cc: Yonghong Song , bpf@vger.kernel.org, linux-mm@kvack.org, Alexei Starovoitov , Andrii Nakryiko , kernel-team@fb.com, Luigi Rizzo , liam.howlett@oracle.com, akpm@linux-foundation.org Subject: Re: [PATCH mm/bpf v2] mm: bpf: add find_vma_no_check() without lockdep_assert on mm->mmap_lock Message-ID: <20210908135326.GZ1200268@ziepe.ca> References: <20210908044427.3632119-1-yhs@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b=oC3gFobF; spf=pass (imf12.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.160.171 as permitted sender) smtp.mailfrom=jgg@ziepe.ca; dmarc=none X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 7358B10000AA X-Stat-Signature: twd81btg688ed1uhzsig6tw8hokpw9sj X-HE-Tag: 1631109208-712319 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 Wed, Sep 08, 2021 at 02:20:17PM +0200, Daniel Borkmann wrote: > > The warning is due to commit 5b78ed24e8ec("mm/pagemap: add mmap_assert_locked() annotations to find_vma*()") > > which added mmap_assert_locked() in find_vma() function. The mmap_assert_locked() function > > asserts that mm->mmap_lock needs to be held. But this is not the case for > > bpf_get_stack() or bpf_get_stackid() helper (kernel/bpf/stackmap.c), which > > uses mmap_read_trylock_non_owner() instead. Since mm->mmap_lock is not held > > in bpf_get_stack[id]() use case, the above warning is emitted during test run. > > > > This patch added function find_vma_no_check() which does not have mmap_assert_locked() call and > > bpf_get_stack[id]() helpers call find_vma_no_check() instead. This resolved the above warning. > > > > I didn't use __find_vma() name because it has been used in drivers/gpu/drm/i915/i915_gpu_error.c: > > static struct i915_vma_coredump * > > __find_vma(struct i915_vma_coredump *vma, const char *name) { ... } > > > > Cc: Luigi Rizzo > > Fixes: 5b78ed24e8ec("mm/pagemap: add mmap_assert_locked() annotations to find_vma*()") > > Signed-off-by: Yonghong Song > > Luigi / Liam / Andrew, if the below looks reasonable to you, any objections to route the > fix with your ACKs via bpf tree to Linus (or strong preference via -mm fixes)? Michel added this remark along with the mmap_read_trylock_non_owner: It's still not ideal that bpf/stackmap subverts the lock ownership in this way. Thanks to Peter Zijlstra for suggesting this API as the least-ugly way of addressing this in the short term. Subverting lockdep and then adding more and more core MM APIs to support this seems quite a bit more ugly than originally expected. Michel's original idea to split out the lockdep abuse and put it only in BPF is probably better. Obtain the mmap_read_trylock normally as owner and then release ownership only before triggering the work. At least lockdep will continue to work properly for the find_vma. Jason