Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1588765ybh; Thu, 23 Jul 2020 12:42:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnVESG9FnO7ooZFqSawRQaDi6zmb0QJl/T84p3qhf4b3nhFNGM+PvUk1bv8sFarL2J0UcO X-Received: by 2002:a17:906:7c54:: with SMTP id g20mr6019265ejp.460.1595533371731; Thu, 23 Jul 2020 12:42:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595533371; cv=none; d=google.com; s=arc-20160816; b=tbWHlFuzWGaNbwcrRRvwfaa84D+Yf1gy7ozxPb1prVr1jVkbRwR90/9NPZt+8ryKPc 82YhY5T+I+Y4J8NTaoFEFsHgs/0irMiGOYzji4ml+gVvSugyoQ8qy/Tc7JF4tVfrYFcG Rdd+fyJIRkrtIXpKstVbA1vlgUdDxgfUfjdx279k22lkazQLKpnDTE45daYd17LfASAw tFi7f17MvnDZYgiMI5CUBJdOzFuDutIQERC8nWypxwNREmNoE/S0rDUkbiAoDd739lO1 wBZsyOWx1swGjJXE8yTyAFxNE9Wcpa1ZjKtA8S5qClvoHjhIheoVBl2yxE32YcNUtY2k zxIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=yDa3ZkgaE+WuzZtaVFiJyzytWneTWKSFcpZNER2Xyo8=; b=R7quf4RPY8Qu5AMXNiWO9HSl4U0boGq+Y780cVW2PSLhtEa3eRkI+H3+n4QnuNsWw7 N6T/ojVyzUqvbd0NA0dYJT7EckUvDzwzk0ArmPcOW/ocFBfVQDq+OBvL6OgxB5YSK4lm 8Hd09Ndi0TKNPDPd7IjZ5p7cpJ/16lOWVvZYiG96J1kT8/zpqZmffYezSENPGlh9BjY6 Kr/3hNaq+/gyUol92MMgyScqxklFl3CGHB8NvariUUXV9e7wpJVyOcy8/sufU+Am0myP XZ68E3l4FWRgDoKconp5fv09bflstSgAMN0TexT+PUt0fZR+NjBx+4cflLlGvQCLZWwl FUpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=bhbwlb65; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b18si2497073ejz.319.2020.07.23.12.42.28; Thu, 23 Jul 2020 12:42:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=bhbwlb65; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726331AbgGWTlt (ORCPT + 99 others); Thu, 23 Jul 2020 15:41:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726146AbgGWTls (ORCPT ); Thu, 23 Jul 2020 15:41:48 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01A99C0619E2 for ; Thu, 23 Jul 2020 12:41:47 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id q4so2147407edv.13 for ; Thu, 23 Jul 2020 12:41:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yDa3ZkgaE+WuzZtaVFiJyzytWneTWKSFcpZNER2Xyo8=; b=bhbwlb65XluKM2V2sElc/28MQmfFvinSxRA6UNKn8PF0p8CCmL4AyNxxuTsA73ybg4 mzaDpPE17MWH+ODDOmK4ufuktYwq4H0wVyIiNDueQ9TTmWxkJJHvPNhIM2DsJvYFpNLQ E8OqCRcsFhQL8VxPqFGF4UlaIGaijRkiVmp6kwDmrn3qKeO3cf6Yqso++Ivi5tj6bUW/ XX7oU7Ye6kMirSQ4D0eIDTV3u0dw+4/1ELAq73l63Wy2QGVV1Jf5LGFhBtpETNktedO0 q0eNDR15gPxmN2N3JhLL4JL4rEJHZvPUcsrzCD1/S3zDLViMqnNSKouBWVNcp7a4g4Fs pGKg== 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=yDa3ZkgaE+WuzZtaVFiJyzytWneTWKSFcpZNER2Xyo8=; b=SoINqdYn3bWNl6dnLGfGSiuBRWjyDZzp8PC0nKur5e2xsQasNHEguTPLQ2mMOED75B swC+FCGRqQSavsE2UDnDqK7SxVLFMVKUXvZGAdfXy+Yc9IAT0J9WQtzkPoxR5oWVjlkX jlXHhCsDPcDNjKOp20a+JYO9UYVHzZcup8dOQ10d1s1baMYealML/9GU+BlcF6lZd5X7 lkAGjdJtIpA0X5xJ4Yn4TwYHBAlwqJnKcDM7mZArtOnXpryMwfZjYjarfOSBqqNQJdRU nHHZ/Bp/UQ7JAZNRpYRVS/LU9KXAJy9cRiLEn5TjZ3SNoU7lIGik8kHWiJC1V20/PFzC ncJA== X-Gm-Message-State: AOAM530wQ5orI+9GCXcHmLojS9aGNttgse1mD/d+zbzlCBMmzwCXuhOc +oJgSWFOYYE4On4K+2fYAXx6/wv05R3nhmkvLdphhg== X-Received: by 2002:a05:6402:14c1:: with SMTP id f1mr5907076edx.342.1595533306590; Thu, 23 Jul 2020 12:41:46 -0700 (PDT) MIME-Version: 1.0 References: <20200717205322.127694-1-pasha.tatashin@soleen.com> <20200717205322.127694-2-pasha.tatashin@soleen.com> <20200723180902.GV3673@sequoia> <20200723183909.GW3673@sequoia> In-Reply-To: <20200723183909.GW3673@sequoia> From: Pavel Tatashin Date: Thu, 23 Jul 2020 15:41:10 -0400 Message-ID: Subject: Re: [PATCH v1 1/1] loop: scale loop device by introducing per device lock To: Tyler Hicks Cc: axboe@kernel.dk, linux-block@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > > > - atomic_inc(&lo->lo_refcnt); > > > > -out: > > > > + err = mutex_lock_killable(&lo->lo_mutex); > > > > mutex_unlock(&loop_ctl_mutex); > > > > > > I don't see a possibility for deadlock but it bothers me a little that > > > we're not unlocking in the reverse locking order here, as we do in > > > loop_control_ioctl(). There should be no perf impact if we move the > > > mutex_unlock(&loop_ctl_mutex) after mutex_unlock(&lo->lo_mutex). > > > > The lo_open() was one of the top functions that showed up in > > contention profiling, and the only shared data that it updates is > > lo_recnt which can be protected by lo_mutex. We must have > > loop_ctl_mutex in order to get a valid lo pointer, otherwise we could > > race with loop_control_ioctl(LOOP_CTL_REMOVE). Unlocking in a > > different order is not an issue, as long as we always preserve the > > locking order. > > It is probably a good idea to leave a comment about this in the > lo_open() so that nobody comes along and tries to "correct" the > unlocking order in the future and, as a result, introduces a perf > regression. > Makes sense, I will add a comment about it. Thank you, Pasha