Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2318961ybb; Fri, 27 Mar 2020 03:20:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvClXbP8nYp22uWdoki6HJSvJM1LPITFyBKvh+Hg8jnLV/I0xlTmUs9YAvF+44Y/RoqqjXk X-Received: by 2002:a4a:db7b:: with SMTP id o27mr6073478ood.25.1585304414505; Fri, 27 Mar 2020 03:20:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585304414; cv=none; d=google.com; s=arc-20160816; b=ii9kIfVY553S95Mitju7/Lw60Z5ZLASTRgNX+4Isa5/M6s4Rk4Nmv87XrLqEdQcZpb kjiV0MM0xBDGO/G1b8wZ1flL0b5/Eht5geZKgqAawFAVrUGlAeQTot2VbxpOv1CaDARN StvfjkMm0jSkCr8ISuccrTeAvpzJv3/HMuNWegQvSH9lZuJelI4/tj6LZCthLTZ5Z5TG 4OXjglz1dwLn2KF5qT5DuqhanwrO3uc/ANcQBV1dV8JkLbvn7//2oNeuYrEPPlvfA+yU jh0WEotJoo9NnYyur8c66ck9OjNX5d6YZ4fbAqc50FOIK30jtt7cOhvgFwF7fUn0uPJI mW1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:in-reply-to:cc:references:message-id :date:subject:mime-version:from:content-transfer-encoding :dkim-signature; bh=bdNljni0qGfsEsOjwWI52DzmcTz0dDp50+ihOjqpjX0=; b=QsB19rqcmveyZvRQssAu+5Q0P6tZyMkVHEaZ/S2MFvgPL2geFWfpBg/4bVu5SRc421 +RZX41OrL0ZlcCNz6ZRspx7NYvLkGgmWWfAT3SUnBkQLl7Y9skLOXTLg2Mmp4BPtTk5B 05VdWPI1L9E2u1JRe/5S53FMbMBs/nVgS2uktquRF3uJlgi+ch2k6MKhJgzbZPfjp8LA a8EWFtoieUFsfob0U6x6JWujKqAJ+B14+6eLm5KT213RbJmGcepKFWVvQY5LkuAF1WVa rWI4Rl9TbDxIiNH2xWXxVJZ9mC6fX85b8IjmJBxm1QwVE+5+juydYs08N4btWc8UGAea Emig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=iZLH4CfW; 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 x5si2056995ooj.75.2020.03.27.03.20.00; Fri, 27 Mar 2020 03:20:14 -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=pass header.i=@lca.pw header.s=google header.b=iZLH4CfW; 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 S1726217AbgC0KTk (ORCPT + 99 others); Fri, 27 Mar 2020 06:19:40 -0400 Received: from mail-qk1-f173.google.com ([209.85.222.173]:41915 "EHLO mail-qk1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbgC0KTk (ORCPT ); Fri, 27 Mar 2020 06:19:40 -0400 Received: by mail-qk1-f173.google.com with SMTP id q188so10176342qke.8 for ; Fri, 27 Mar 2020 03:19:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=bdNljni0qGfsEsOjwWI52DzmcTz0dDp50+ihOjqpjX0=; b=iZLH4CfWYW4cjqrXxp8hEXnciNngJ41CUmtDM46s1G8iLlpgwhFhPuhzn0OKbYGNyJ UGC1Cau/q2B/nftm+byUQYU0u0cchFev0vLGr5uAr3C/EQWg9NodE14zhXNhcDGBywvA ZkKf+4BeRxRAr1naEEHlSMu4DqYYO8fuk++LjVdW2mFMM/P/FH5/A1tHhn4kun9cl1S9 uaCJAnzjkm+41xPi1aDWg/RQDJVcl5A8TpSxIHVXjXSnmwf5dwxZKNwEVmmonwgfZlMj Tlf5ASjwjGevoG7fD2coXYA6wyMti67P9S9eRoFw2GwPVEp1FkDjUgGOY3P60vRa84mB 8w7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=bdNljni0qGfsEsOjwWI52DzmcTz0dDp50+ihOjqpjX0=; b=a3sHcXhTT5QrDcw/vC+5z8tppNIV/c3K760QFn5i4urgN/cnmUpyGeaIRSInwT9nTx C+CfcGEi+mz/hdjfsOnH6bcJKqQwXRxHOPWINfGOqVuFgNLhxArIZXr2DVeQ7nxdsPrP 4KIZlOcirJ2jMHwYuEGKMiri1OaqsEOyzQVKwwnBZjnTVcRYXM0PIecufTe02auPYnza G9TLfODu/+6vzflmWK4LF3E8674GKuguzZKq/gSfig8wbs+SvtMCwDGBOGrTivmkamPz E9SbTzkMrvKvkEUPfM6npVavhUN+IfAXfzZ1W9kjNkhIT/vdLFWCtL+1sFT4mZn4qJAL pUmw== X-Gm-Message-State: ANhLgQ0xfeLHVEi3TCU4A68DM9rrdRC3aXQVktkBnUoSkrFqCelB6DKV YxyjRQNWe53q+gSIGUWJLVWTSw== X-Received: by 2002:a37:cc1:: with SMTP id 184mr13416103qkm.430.1585304379199; Fri, 27 Mar 2020 03:19:39 -0700 (PDT) Received: from [192.168.1.183] (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id l45sm3639875qtb.8.2020.03.27.03.19.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Mar 2020 03:19:38 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable From: Qian Cai Mime-Version: 1.0 (1.0) Subject: Re: [PATCH -next] locking/percpu-rwsem: fix a task_struct refcount Date: Fri, 27 Mar 2020 06:19:37 -0400 Message-Id: References: <20200327093754.GS20713@hirez.programming.kicks-ass.net> Cc: mingo@redhat.com, will@kernel.org, dbueso@suse.de, juri.lelli@redhat.com, longman@redhat.com, linux-kernel@vger.kernel.org In-Reply-To: <20200327093754.GS20713@hirez.programming.kicks-ass.net> To: Peter Zijlstra X-Mailer: iPhone Mail (17D50) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Mar 27, 2020, at 5:37 AM, Peter Zijlstra wrote: >=20 > If the trylock fails, someone else got the lock and we remain on the > waitqueue. It seems like a very bad idea to put the task while it > remains on the waitqueue, no? Interesting, I thought this was more straightforward to see, but I may be wr= ong as always. At the beginning of percpu_rwsem_wake_function() it calls get= _task_struct(), but if the trylock failed, it will remain in the waitqueue. H= owever, it will run percpu_rwsem_wake_function() again with get_task_struct(= ) to increase the refcount. Can you enlighten me where it will call put_task= _struct() in waitqueue or elsewhere to balance the refcount in this case?=