Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4420670pxa; Mon, 10 Aug 2020 08:40:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD6YQs80K7RxHoEKXvFjaD/GTQTfIoYxJF9F3zNzZto/NiWTSVXhH8ervT5vMVk4v7uakh X-Received: by 2002:a50:935a:: with SMTP id n26mr21829960eda.107.1597074050373; Mon, 10 Aug 2020 08:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597074050; cv=none; d=google.com; s=arc-20160816; b=V5al8XjUz5WDoLJQEifYI5Jx2wTOz+3pDG50FUbtvwf4xovnuYw777g+6y2Z53JvrF vlv1ZBfNzkQhwdWtTCeqFzLUMHOd8jgKYO9vQ2SJYfvWquX72U0dDjEReBLGVSt/QpxE Z5nV+uJNOsyqtQqrQJ5iOzlCMz5cpbpGFQdkd+3JW+WvQFebdmZJxuXz2jVXSt84XlZ7 zwiBvP7SWWdRtwi0yYeMg9myVtZAQHkwvAeNHHOswv7NTnOBqaXCdCL4qL4oX7n20uBI XJkQbeA0LPyeI5ldFGjjr7lTXlh7P34I3dN0iOBfEDritvHWRqqzEk0XAi1PIIGWOUtZ 9hKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sQESxLQ9j3BhdfszMHutiKRJA/2ITiuGEv+bwYkYCzY=; b=rDXk3syhPR7abXSjnYzEEwJ0/xzSkSsUV42cLRsXj6cM4fKLZHjhTq3uGgQwraEiMM 0CvvYxiUiL/14n6TR8MC7OHVOaEGBPhuDDcHk8aoemWbsGKJc0+dSui7Z+KeNaD3AEFJ 1e8AfIoAYn0dVnH/Ty1UWuPutDu3AjmaCd6Y2Kq7tIG2YzRuzwna+bFGTT1LYr3bjHOo 6K0Pp59996O1EIIR42/uh1EKBWR1pbbIs/qGxsBob0269Rg8xqOguPSZW6Yo1Zdb3P/8 2OwESJedOhmcOE9tgS6nXpDadLeLfuFIiHGQS8Uuh4M4kTaIId1mnM+j9SWsOGh47KH3 TYIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eesmhdwr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q6si10610239edn.165.2020.08.10.08.40.27; Mon, 10 Aug 2020 08:40:50 -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=@kernel.org header.s=default header.b=eesmhdwr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729238AbgHJPj6 (ORCPT + 99 others); Mon, 10 Aug 2020 11:39:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:52156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728869AbgHJPj4 (ORCPT ); Mon, 10 Aug 2020 11:39:56 -0400 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1C4B022D6F; Mon, 10 Aug 2020 15:39:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073995; bh=YOM+g/TR562Qnqd9mjPiiw/B/53j8zLV2C2vybC4Y3A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eesmhdwrQECMSX9NuYuFlxIep7RfnnDf/qDMe8aSjXl/LMrf2xCxCGXH7j00wCKMF 7NOXfKahT5R1UMzZvwNllwJv6n4hF1rCjZlTOXz2t3fpatBC2a3U9eY/fmlzxYg90R doF7JwzAYFgNCJ8lbhzMwAqyI6bye5iRXRRASkDI= Date: Mon, 10 Aug 2020 16:39:28 +0100 From: Mark Brown To: =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: Dmitry Osipenko , Liam Girdwood , linux-kernel@vger.kernel.org Subject: Re: regulator: deadlock vs memory reclaim Message-ID: <20200810153928.GD6438@sirena.org.uk> References: <20200809222537.GA5522@qmqm.qmqm.pl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="OaZoDhBhXzo6bW1J" Content-Disposition: inline In-Reply-To: <20200809222537.GA5522@qmqm.qmqm.pl> X-Cookie: Walk softly and carry a megawatt laser. User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --OaZoDhBhXzo6bW1J Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 10, 2020 at 12:25:37AM +0200, Micha=C5=82 Miros=C5=82aw wrote: > regulator_lock_dependent() starts by taking regulator_list_mutex, The > same mutex covers eg. regulator initialization, including memory allocati= ons > that happen there. This will deadlock when you have filesystem on eg. eMMC > (which uses a regulator to control module voltages) and you register > a new regulator (hotplug a device?) when under memory pressure. OK, that's very much a corner case, it only applies in the case of coupled regulators. The most obvious thing here would be to move the allocations on registration out of the locked region, we really only need this in the regulator_find_coupler() call I think. If the regulator isn't coupled we don't need to take the lock at all. > Basically, we have a BKL for regulator_enable() and we're using ww_mutex > as a recursive mutex with no deadlock prevention whatsoever. The locks > also seem to cover way to much (eg. initialization even before making the > regulator visible to the system). Could you be more specific about what you're looking at here? There's nothing too obvious jumping out from the code here other than the bit around the coupling allocation, otherwise it looks like we're locking list walks. --OaZoDhBhXzo6bW1J Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl8xajAACgkQJNaLcl1U h9BNnQf/VnLzsKZ8MKsJKrUcITrwjL4Ty5NlAVZt14rULY5df4rpXxQ97YKGkwjD GK0sP3nSmNHte2WUXjPfP86H+JuWk0tpOv6g06miuuFeC0bdrSZ17dchZikGM7n+ cGQHJ7x50NRtIRjjLE01h+huS61aYd/XBGZPcTpPgx8r724FoNGUWq7Ufyw0vc5f tZFVl0F5BvDmwwgtsFBkv16VtPyDMoZp7W/oEBaECcH1myFmOMdyZ/NYQ4TfEEgt NADH2+Z6wFJGEH4B6nkXkxAY2lY3Ya5eq8UiE9TuQru6qre59l5rC7lQTKRcRNcf /O6+7aYsRw36Ij/2ViyNCV929Hn6tQ== =oiI0 -----END PGP SIGNATURE----- --OaZoDhBhXzo6bW1J--