Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3249807imu; Sat, 24 Nov 2018 01:04:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/UjkXp9iqPF1aXCczs+fvqRMirsSuAWfF3AutIrr73B7aO0matRWlAOoYBapIrfaGSIH2bU X-Received: by 2002:a63:3546:: with SMTP id c67mr17484929pga.284.1543050242345; Sat, 24 Nov 2018 01:04:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543050242; cv=none; d=google.com; s=arc-20160816; b=TY6k1qQoRI5OdBRfhIiGqCZ/ubcpllxhS/QFPWl/rYEtrBUlTh0XFd/KwO3isDRnZV JQHU2UeYe1TJChdCuGvHe6jJqhuMBDoiq4q+N0x8Hm/uZmmiyVFpQCewG/q9/n6tqAP6 wQIFnuySWnmiBYPR3JWvx70sUv/i+7IyRkfjrPmAmixcF3QdwIEMebraDyc582ah8zTw zlIlRlN9rMT9UiDKRpegYbodSmrxoPz/A/nHj6zULlZMNPx9NlebOQ/1L2tdm4DGdFtv fkIyFstrtafaJ6X+9/luGeEQX0iHG8mYrJeCuXjfi2cZ5EDwPUJ4Pz7Z9wqaz8WT4ldE wk5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=DWf+CdinECn4Za/kLVV1HGwA2P0KfHUjfv05jMAlQVg=; b=K/Z5AtZnSR9Wbkndg02joXnTmWGzhb++mdRXxS1sF8BNALGJR2hK2yAfpGPxjsry6W GRbrc8UQL8aAJ/wNYt/0EiF+XHYrw0uUorjDUwG71nUQdx7pslf3pL8XNqcUdIisdIpN ftwPtV4nCSLbF4RJrRGJTy5q8H8Aw0YN2CbY5uKuI/uwbD4CA/lQspMEfrLPA60SyQEC fCMREegkZ0IDjP6GieYS/YBkMOCreSrzW7tznqBsSCD2nVq7KtdEJ0VlE56BCUjSL8PG +tys5gTTc/jsmQMKvu6qiI/YFK+CbUF+RSflcB8O4OEqkXa2w5iDMCFf3hV9c45CjVCs T9aA== ARC-Authentication-Results: i=1; mx.google.com; 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 l3si23620095pld.155.2018.11.24.01.03.47; Sat, 24 Nov 2018 01:04:02 -0800 (PST) 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; 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 S1726586AbeKXSUj (ORCPT + 99 others); Sat, 24 Nov 2018 13:20:39 -0500 Received: from lgeamrelo13.lge.com ([156.147.23.53]:44168 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726125AbeKXSUi (ORCPT ); Sat, 24 Nov 2018 13:20:38 -0500 Received: from unknown (HELO lgeamrelo01.lge.com) (156.147.1.125) by 156.147.23.53 with ESMTP; 24 Nov 2018 16:33:07 +0900 X-Original-SENDERIP: 156.147.1.125 X-Original-MAILFROM: chanho.min@lge.com Received: from unknown (HELO kernel.lge.com) (165.186.175.97) by 156.147.1.125 with ESMTP; 24 Nov 2018 16:33:07 +0900 X-Original-SENDERIP: 165.186.175.97 X-Original-MAILFROM: chanho.min@lge.com From: Chanho Min To: Jaroslav Kysela , Takashi Iwai , Vinod Koul , Daniel Mentz Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Seungho Park , Jongsung Kim , Wonmin Jung , Jaehyun Kim , Hyonwoo Park , Chanho Min Subject: [PATCH] ALSA: pcm: Fix starvation on down_write_nonblock() Date: Sat, 24 Nov 2018 16:32:43 +0900 Message-Id: <1543044763-31843-1-git-send-email-chanho.min@lge.com> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 67ec1072b053 (ALSA: pcm: Fix rwsem deadlock for non-atomic PCM stream) fixes deadlock for non-atomic PCM stream. But, This patch causes antother stuck. If writer is RT thread and reader is a normal thread, the reader thread will be difficult to get scheduled. It may not give chance to release read locks and writer gets stuck for a long time or forever if they are pinned to single cpu. To fix this, The writer gives reader a chance to be scheduled by using the minimum msleep() instaed of spinning. This is for concept, We may need to change the function name and comments or suggest another approach. Signed-off-by: Chanho Min --- sound/core/pcm_native.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 66c90f4..88d4aab 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -96,7 +96,7 @@ static DECLARE_RWSEM(snd_pcm_link_rwsem); static inline void down_write_nonblock(struct rw_semaphore *lock) { while (!down_write_trylock(lock)) - cond_resched(); + msleep(1); } #define PCM_LOCK_DEFAULT 0 -- 2.1.4