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=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no 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 1C5FAC4727E for ; Thu, 1 Oct 2020 23:56:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C44A721D24 for ; Thu, 1 Oct 2020 23:56:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XaP00L7E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733166AbgJAX4T (ORCPT ); Thu, 1 Oct 2020 19:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727017AbgJAX4S (ORCPT ); Thu, 1 Oct 2020 19:56:18 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96A19C0613D0 for ; Thu, 1 Oct 2020 16:56:18 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id a3so312715ejy.11 for ; Thu, 01 Oct 2020 16:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=huRrm9uRTF6EQtP3Gb3rzv3n9rl5QC5dhEPKA1yWUwo=; b=XaP00L7EdhotRxKDmoF2aYq7K8neRHGRpPiSpCbWUMRbbHRzomvmHNio8rp7Bqld9k 6sTEPllvCqsoowPLp5OqORiyIKcW9T3Nnve22rGNj4up9gkv9fvV2sJFnhhzQLH9spc7 gPewysecSzSqjCaI+kmUiKHcR15RTvcZsOcPERvYwkc3XKv+DA31+BNxlkYr0Yine0qq Wn5Q8Hjelz1j02imtNEGqQTx471nFgRWf41hl+blA8s+LvRVTgtDr6cdpTmNQIDKZ0dL DK6OwtyNLs0JS6FjQKc/0mTfkd/D6xAZVyFdtmlAKKd2kHweSimVSSihZbvTfZk8q9CE Q36A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=huRrm9uRTF6EQtP3Gb3rzv3n9rl5QC5dhEPKA1yWUwo=; b=cPURqjAN7gCoEdXWZsd1GJ00CupifpSHp24IvSc2plRgqXININ2wftzw9JfI64vJEe jef+zsu9BdPCXA07b2VWxTY/2VVYuQ/LBKn30crXm1Q1Dlg2K05hsmddL0c95ZMvxM4L Un2cy7T5C+RNohParOPX0JeHQGz3w2Oze2+FP2ompmwnqR+to38dsPp5fmzaXysy3KoK uqP8p8njgfvq/w9utAF+dmbtbCuvUvhMmMel5UtKoTph+bqTPOTVbMRz8zcfPxpDfRoh 78lP5iTK/UZmlxJLUoevhnU47Fcv0622WZOmRGeM0Wg7esGHmZboGfzs0ZwIbVOsE+9g 2+Xw== X-Gm-Message-State: AOAM530oMBu1QFYgPAO5dcZVUpQCPPLfgUQUHL4e70nLltEz9j5Y9PSb l0SS+eohBhtvWUuC0yYdXiPHyJmu8NSUTGP43fHQEw== X-Google-Smtp-Source: ABdhPJzY0cXU4m7Tu4YFGGwKpafVHVFUjH9rQpY1NNEXp84S0DHdO+CZPKylkQGHz77THxSw1DQrSf3fLkRHOcjxDTw= X-Received: by 2002:a17:906:980f:: with SMTP id lm15mr11072385ejb.184.1601596577053; Thu, 01 Oct 2020 16:56:17 -0700 (PDT) MIME-Version: 1.0 References: <20200930011944.19869-1-jannh@google.com> <20200930123000.GC9916@ziepe.ca> <20200930232655.GE9916@ziepe.ca> <20201001191512.GF9916@ziepe.ca> <20201001234127.GG9916@ziepe.ca> In-Reply-To: <20201001234127.GG9916@ziepe.ca> From: Jann Horn Date: Fri, 2 Oct 2020 01:55:51 +0200 Message-ID: Subject: Re: [PATCH 3/4] mmap locking API: Don't check locking if the mm isn't live yet To: Jason Gunthorpe Cc: Michel Lespinasse , Andrew Morton , Linux-MM , kernel list , "Eric W . Biederman" , Mauro Carvalho Chehab , Sakari Ailus Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 2, 2020 at 1:41 AM Jason Gunthorpe wrote: > On Thu, Oct 01, 2020 at 10:16:35PM +0200, Jann Horn wrote: > > > A subclass isn't right, it has to be a _nested annotation. > > > > > > nested locking is a pretty good reason to not be able to do this, this > > > is something lockdep does struggle to model. > > > > Did I get the terminology wrong? I thought they were the same. The > > down_*_nested() APIs take an argument "subclass", with the default > > subclass for the functions without "_nested" being 0. > > AFAIK a subclass at init time sticks with the lock forever, the > _nested ones are temporary overrides. > > I think what you kind of want is to start out with > lockdep_set_novalidate_class() then switch to a real class once things > are finished. Not sure exactly how :) Huh, is there an API that sets a *subclass* (not a class) at init time? I don't think there is. Anyway, I'm pretty sure I just need to use the normal _nested() locking API. I'm still cleaning up and testing a little bit, but I'll send it out in a short while, unless I run into unexpected trouble. Let's continue this if necessary once there's a concrete patch to talk about. :) 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=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no 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 1F200C4741F for ; Thu, 1 Oct 2020 23:56:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7944B21481 for ; Thu, 1 Oct 2020 23:56:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XaP00L7E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7944B21481 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C6C5F6B0099; Thu, 1 Oct 2020 19:56:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF4F86B009A; Thu, 1 Oct 2020 19:56:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABBC56B009B; Thu, 1 Oct 2020 19:56:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id 7B5926B0099 for ; Thu, 1 Oct 2020 19:56:19 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0DFD38249980 for ; Thu, 1 Oct 2020 23:56:19 +0000 (UTC) X-FDA: 77325018078.30.end97_2c17aa92719f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id E1A1A180B3C85 for ; Thu, 1 Oct 2020 23:56:18 +0000 (UTC) X-HE-Tag: end97_2c17aa92719f X-Filterd-Recvd-Size: 4494 Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Thu, 1 Oct 2020 23:56:18 +0000 (UTC) Received: by mail-ej1-f65.google.com with SMTP id q13so327132ejo.9 for ; Thu, 01 Oct 2020 16:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=huRrm9uRTF6EQtP3Gb3rzv3n9rl5QC5dhEPKA1yWUwo=; b=XaP00L7EdhotRxKDmoF2aYq7K8neRHGRpPiSpCbWUMRbbHRzomvmHNio8rp7Bqld9k 6sTEPllvCqsoowPLp5OqORiyIKcW9T3Nnve22rGNj4up9gkv9fvV2sJFnhhzQLH9spc7 gPewysecSzSqjCaI+kmUiKHcR15RTvcZsOcPERvYwkc3XKv+DA31+BNxlkYr0Yine0qq Wn5Q8Hjelz1j02imtNEGqQTx471nFgRWf41hl+blA8s+LvRVTgtDr6cdpTmNQIDKZ0dL DK6OwtyNLs0JS6FjQKc/0mTfkd/D6xAZVyFdtmlAKKd2kHweSimVSSihZbvTfZk8q9CE Q36A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=huRrm9uRTF6EQtP3Gb3rzv3n9rl5QC5dhEPKA1yWUwo=; b=W4b31g3X1Hu17fuoI+D1F2Ujwr3BnGThPLhuC646bnXLFvh9qRs0jVpmxAFv7U6jl5 qNf/cG2TaB5J3wLRDM3+xlxdu4FivmRTJ8Qb06F2vPUhYeDp7zYaAaTenV/a4vZnoM3g fbHPX4ffS6ssD2Do28Y1Brd/YvymsXu7zwI52En64gSdoxcAKSm2Z/0st75fpY26k0Nl G5hxiPTUx5MWPZRBm+PeJDPTEoz2IXJTHXTqTGkaqX92lOy9BwFctyqqwfyV5Yi0w0R0 5FbkaDqpp5wU0ocmhjqgXbT1+xi6qbVnsHj4UKzvX9lb/Qyr8tYWIMTOMjpiUrmK5GuY wM+g== X-Gm-Message-State: AOAM533J/GcABCspTAyU9SN89c8uLoj+tXlO20bKRdkthyCOjJJJZsFO OO2ahpgZTm30CTtFuAqF1Yru5wUsXM+qMW7wqC9l/A== X-Google-Smtp-Source: ABdhPJzY0cXU4m7Tu4YFGGwKpafVHVFUjH9rQpY1NNEXp84S0DHdO+CZPKylkQGHz77THxSw1DQrSf3fLkRHOcjxDTw= X-Received: by 2002:a17:906:980f:: with SMTP id lm15mr11072385ejb.184.1601596577053; Thu, 01 Oct 2020 16:56:17 -0700 (PDT) MIME-Version: 1.0 References: <20200930011944.19869-1-jannh@google.com> <20200930123000.GC9916@ziepe.ca> <20200930232655.GE9916@ziepe.ca> <20201001191512.GF9916@ziepe.ca> <20201001234127.GG9916@ziepe.ca> In-Reply-To: <20201001234127.GG9916@ziepe.ca> From: Jann Horn Date: Fri, 2 Oct 2020 01:55:51 +0200 Message-ID: Subject: Re: [PATCH 3/4] mmap locking API: Don't check locking if the mm isn't live yet To: Jason Gunthorpe Cc: Michel Lespinasse , Andrew Morton , Linux-MM , kernel list , "Eric W . Biederman" , Mauro Carvalho Chehab , Sakari Ailus Content-Type: text/plain; charset="UTF-8" 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 Fri, Oct 2, 2020 at 1:41 AM Jason Gunthorpe wrote: > On Thu, Oct 01, 2020 at 10:16:35PM +0200, Jann Horn wrote: > > > A subclass isn't right, it has to be a _nested annotation. > > > > > > nested locking is a pretty good reason to not be able to do this, this > > > is something lockdep does struggle to model. > > > > Did I get the terminology wrong? I thought they were the same. The > > down_*_nested() APIs take an argument "subclass", with the default > > subclass for the functions without "_nested" being 0. > > AFAIK a subclass at init time sticks with the lock forever, the > _nested ones are temporary overrides. > > I think what you kind of want is to start out with > lockdep_set_novalidate_class() then switch to a real class once things > are finished. Not sure exactly how :) Huh, is there an API that sets a *subclass* (not a class) at init time? I don't think there is. Anyway, I'm pretty sure I just need to use the normal _nested() locking API. I'm still cleaning up and testing a little bit, but I'll send it out in a short while, unless I run into unexpected trouble. Let's continue this if necessary once there's a concrete patch to talk about. :)