Received: by 10.213.65.68 with SMTP id h4csp29436imn; Tue, 3 Apr 2018 14:50:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+5Q406+d70wNFLhcaWsD5XE/+m1AwhPMIVu/QU8NYEzhz9T7Eto2rOvF5sCfalf+0eKndA X-Received: by 10.99.119.15 with SMTP id s15mr10398201pgc.211.1522792221862; Tue, 03 Apr 2018 14:50:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522792221; cv=none; d=google.com; s=arc-20160816; b=dcmMTKRet2rLzoKNb3k2NY3yduXPmzQzyanKiuJMpFFQ78atFpba6steN3mU/1uLCg XwnlPS7ihF4kDNXSFabFaqdMY4hF9aMthoZUgsPnY3Vopx8g3lhp4LwUxfzy+vGhPX0V TndmpgLG2HODOBivH2WBLNB5OYYaFvbQ6icX5c9HRN2J+G10P2Z7tCTERSRNILhvViTA KDN6nhqKjFfaqn5yDLTiRpV45n5GHbPv5WYQ0z8vtVVSjrOjwMXUdMKG30ViVLEXz8eU 3QFSUgsZg1K+QYf9YnGVLuajiPqsT+p4YxTJCJSRQVwr8KJggRH26ska3CPbIGQhMW2G dHpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Es1qMmTp4XBzVzgqIfNlVjnm9rmjKFd9et2GQOnQXzI=; b=Wn9I0O3aAyWiCks1lM+MyfDAs85ja+7bwtrJVMKi1Jzcoinw8f4RslXPOZyVPiZHqd 59pvM4NCkC7vcEJSSKxVBwW8yy2AzbVN/3D35yQtyzMJZQUyPSHInWQnGRM98wDc0saV SuthDaMucMSnegsyGPOZc49dG3aLQLZicbJ8W4iqESrVVYOvD2M/LZnYHcSy/MsquYYR 5Glf0ZvrD8KaMHdZ1dmW/xnZ1B0s4NbKZCKMkAnEZMVfJH0NrtkzicyETVb43zrJbEdB 2nKIib/zDut9TLI1KyBOT7kBvXZP+iMlU34cCYfbFNOQ/Pntu/WuhAtP4uFDKa/L+vef T0Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=QQ0zenyZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k26si2584676pgn.502.2018.04.03.14.50.07; Tue, 03 Apr 2018 14:50:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=QQ0zenyZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753864AbeDCVsM (ORCPT + 99 others); Tue, 3 Apr 2018 17:48:12 -0400 Received: from merlin.infradead.org ([205.233.59.134]:43092 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753121AbeDCVsL (ORCPT ); Tue, 3 Apr 2018 17:48:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Es1qMmTp4XBzVzgqIfNlVjnm9rmjKFd9et2GQOnQXzI=; b=QQ0zenyZ50dDjGXM1gRmnOjpHo AEF2fatklegEMaeUMT/d889cqkfD3h8Oty9bM71+Y+Lw6RNigdfwwuvvrDIKTlQvJAB+SuzsReN5k VErMqS3wKHuXRWfh8CISAw3tNmkQVGhOV5w4y28fpQV/UKxygjfmlw19mznIsBxGkrPN1uIhq0Uhh UbGdHT4MWtPyqvhlHcUh3ouCVnQqprUXmY/vpEYcL2TdZAuUlmOe+MBNQ9d0tnsooyrJKqnakYfjB Nu2GvLX+PP9+bQVa8KXnjafMzOlVXD5Jy37vZUWj6RRmDzFK20LYJggEy5Kq9O6/JV3K0lH83YSIo xy9WJCtQ==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=dragon.dunlab) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1f3TmV-0006ba-0p; Tue, 03 Apr 2018 21:47:55 +0000 Subject: Re: [PATCH v2 1/3] locking: Document the semantics of spin_is_locked() To: David Howells , Alan Stern Cc: Andrea Parri , paulmck@linux.vnet.ibm.com, Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, Andrea Parri , Will Deacon , Boqun Feng , Nicholas Piggin , Jade Alglave , Luc Maranget , Akira Yokosawa References: <7471.1522791794@warthog.procyon.org.uk> From: Randy Dunlap Message-ID: <91b57513-99be-7b77-ebe2-a7c2a121475f@infradead.org> Date: Tue, 3 Apr 2018 14:47:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <7471.1522791794@warthog.procyon.org.uk> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/03/2018 02:43 PM, David Howells wrote: > Alan Stern wrote: > >> + * Returns: 1 if @lock is locked, 0 otherwise. >> + * However, on !CONFIG_SMP builds with !CONFIG_DEBUG_SPINLOCK, >> + * the return value is always 0 (see include/linux/spinlock_up.h). >> + * Therefore you should not rely heavily on the return value. > > Seems reasonable. > > It might also want to include a note that the lock isn't necessarily held by > your own CPU. I would also use "=n" rather than "!", so maybe something like: > > * Returns: 1 if @lock is locked, 0 otherwise. > * > * Note that the function only tells you that the CPU is seen to be locked, the CPU is locked?? > * not that it is locked on your CPU. > * > * Further, on CONFIG_SMP=n builds with CONFIG_DEBUG_SPINLOCK=n, the return > * value is always 0 (see include/linux/spinlock_up.h). Therefore you should > * not rely heavily on the return value. > > David > -- ~Randy