Received: by 10.223.185.116 with SMTP id b49csp1967109wrg; Mon, 12 Feb 2018 01:50:58 -0800 (PST) X-Google-Smtp-Source: AH8x226pbqHMFlVCkJQ8RyC4UWWwnC8R/FLJqXVnrWBJmCGFSChB/pR4of6Sw6rJIZZMFm/+8m/c X-Received: by 10.98.201.129 with SMTP id l1mr9566269pfk.76.1518429058697; Mon, 12 Feb 2018 01:50:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518429058; cv=none; d=google.com; s=arc-20160816; b=C2ktYLAzLfk+mOfH5KNns3yyIOzG+KfSt7GhcGtWbCxcL9YZ8Gkcb0ttBpnCJFdN8d zZyVL1o3fcYKL2MCn9JVu5A8llfApG89AZ966186YgpNSq2ZIoeMgZv82wQZJylWh9MH 3/mKNNynbEYy/RhfSDVyR/YQYUzplp4y2/ZLdmcbXrW+dgZWBdl10B+GPhO8ukNM2zNo YlVfYyZ8FRSkVSnPZjuehZwvYgiSOYWNU4Qit4FfwgnzS4vt5EUqReA2198yjigfUUPZ hwizAFHXXD0yFkaobhdz4GeIXK7ZgR5sDGg1f5Y8Vbk5IcqumG8THO9fjvb0BEMzKCXL vvow== 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:mime-version :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:arc-authentication-results; bh=E+rpEBtFTH7rpO7ZX5Zpdx3l1WYUobrsmzseXatbbwI=; b=fGyl5kOzyczIOi9DmA5kwGSFN+XdQEqqlQMs/wlFpYLbc6KiJO/xn6wF3m3YK9pB5D fJU8SbhVOOu8gZiisndiOPJQptfQqxRoiVkXKYieeF0oRuxjOd7qyPkbTR5VN5U5ITDT 9/KR5ET3Rltwye6b+fN7mIzEJ1nMY3/a1PXgGBPSEmJy4aRb7STHxX9dxWjj/hqPWhLm x1DYm7q+HxUvv8ELvzWOnxqJ07YFh46wHwqRjpcmINvw6BJZHQxNRRiwhsGUT3V79auP aGXwSIEjyITtOB2xkC30WW3TJYYi60r+y42vAVV3MTzR7Br9R+Z1yI/Ee82HuC+hxmzR MncQ== 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 h14si923071pgv.447.2018.02.12.01.50.42; Mon, 12 Feb 2018 01:50:58 -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 S932756AbeBLIe1 (ORCPT + 99 others); Mon, 12 Feb 2018 03:34:27 -0500 Received: from mx2.suse.de ([195.135.220.15]:34876 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750801AbeBLIeZ (ORCPT ); Mon, 12 Feb 2018 03:34:25 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 26E78AC79; Mon, 12 Feb 2018 08:34:24 +0000 (UTC) Date: Mon, 12 Feb 2018 09:34:24 +0100 Message-ID: From: Takashi Iwai To: Ben Hutchings Cc: stable@vger.kernel.org, Greg Kroah-Hartman , LKML Subject: Re: [PATCH 4.4 20/87] ALSA: pcm: Allow aborting mutex lock at OSS read/write loops In-Reply-To: <1516750548.3417.34.camel@codethink.co.uk> References: <20180115123349.252309699@linuxfoundation.org> <20180115123351.309626066@linuxfoundation.org> <1516750548.3417.34.camel@codethink.co.uk> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 24 Jan 2018 00:35:48 +0100, Ben Hutchings wrote: > > On Mon, 2018-01-15 at 13:34 +0100, Greg Kroah-Hartman wrote: > > 4.4-stable review patch.  If anyone has any objections, please let me know. > > > > ------------------ > > > > From: Takashi Iwai > > > > commit 900498a34a3ac9c611e9b425094c8106bdd7dc1c upstream. > > > > PCM OSS read/write loops keep taking the mutex lock for the whole > > read/write, and this might take very long when the exceptionally high > > amount of data is given.  Also, since it invokes with mutex_lock(), > > the concurrent read/write becomes unbreakable. > > > > This patch tries to address these issues by replacing mutex_lock() > > with mutex_lock_interruptible(), and also splits / re-takes the lock > > at each read/write period chunk, so that it can switch the context > > more finely if requested. > [...] > > @@ -1414,18 +1417,18 @@ static ssize_t snd_pcm_oss_write1(struct > >   xfer += tmp; > >   if ((substream->f_flags & O_NONBLOCK) != 0 && > >       tmp != runtime->oss.period_bytes) > > - break; > > + tmp = -EAGAIN; > >   } > > + err: > > + mutex_unlock(&runtime->oss.params_lock); > > + if (tmp < 0) > > + break; > >   if (signal_pending(current)) { > >   tmp = -ERESTARTSYS; > > - goto err; > > + break; > >   } > > + tmp = 0; > >   } > > - mutex_unlock(&runtime->oss.params_lock); > > - return xfer; > > - > > - err: > > - mutex_unlock(&runtime->oss.params_lock); > >   return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp; > >  } > [...] > > Some of the "goto err" statements in the loop are conditional on tmp <= > 0, but if tmp == 0 this will no longer terminate the loop. Is that > intentional or a bug? The patch rather fixes the endless loop: the signal_pending() check is added after goto err, so that it aborts the loop properly. thanks, Takashi