Received: by 10.223.176.46 with SMTP id f43csp33972wra; Tue, 23 Jan 2018 15:36:33 -0800 (PST) X-Google-Smtp-Source: AH8x227p7Zy5s4mKEi8QJoGIS+lSULyp4KqAN0TxS/zbsAJuYeEzKJ247WROfVWb9/gylfTfo6Xd X-Received: by 2002:a17:902:6b83:: with SMTP id p3-v6mr6371481plk.18.1516750593322; Tue, 23 Jan 2018 15:36:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516750593; cv=none; d=google.com; s=arc-20160816; b=KLppmqJoAPVST9a9XqcOGCDvzV3QYg+qXgePaIjS10F2am2VhaUFX4inZANmjjOyl9 uOmlWFXQEBHDjT9HxQInEXvlfDE8sNWYNeWkDs/qoT1MPXeYMxrROXsjF12FZGfkrZU0 Q0fIhmBV7LfzS5ZbP5LIOr3ouak7q5o1NGUoemM50jz1rvwWq1j8EDyD+9ehBIpfozXx 9rMYzibD4nvWYEyoIgec0ZrmvgHMbZF7xbt5Xi8rW52trX5FB/qvB5aY4X4RD4qUh9F+ PEbGhioONKnEtj+UpBgyp6mG9WK2kWAT3dbdgReJkT6eskriA6ipuLamKDjYtfCoThr7 oTdA== 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 :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=SYXGOvU5eZBpjOmqq2yps8ZSoSnDSKsIHcgAF2i0sQ8=; b=ik3ZO/EGtsedk0cse5IfuPUMxoVDOJ7vIvjDm92RKOAbFDnodWow+7qTYuiXm1BlA6 1tHn8ZXPpwiQPN0/s994Q0LkFg2d/KODYJZSHmC9qjTDVgwizhrMMcs+JzY62BLXtedk R0+wojkGjPsZD/GjzM9iyTyxyaWTOtdt2XyraZji13zuS9dg1UuFc9XZ9L9tc+3auXa8 mWsrcFVzXOVqgwIc22z7spUisA9j9t974f0oC+bGe6VZzqPCEbBGKQar0ZqtwAcTANfY ZRB2rNOoUTZS5dfrv0SAwFNaFCFjf7+j6HmoTQ+3zARSXWAECHDQ26+BvenUE4IAVNi3 rt2w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p6si12421029pga.651.2018.01.23.15.36.18; Tue, 23 Jan 2018 15:36:33 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752099AbeAWXfy (ORCPT + 99 others); Tue, 23 Jan 2018 18:35:54 -0500 Received: from imap1.codethink.co.uk ([176.9.8.82]:42726 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807AbeAWXfx (ORCPT ); Tue, 23 Jan 2018 18:35:53 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126] helo=xylophone) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1ee86a-0006uM-Rd; Tue, 23 Jan 2018 23:35:52 +0000 Message-ID: <1516750548.3417.34.camel@codethink.co.uk> Subject: Re: [PATCH 4.4 20/87] ALSA: pcm: Allow aborting mutex lock at OSS read/write loops From: Ben Hutchings To: Takashi Iwai Cc: stable@vger.kernel.org, Greg Kroah-Hartman , LKML Date: Tue, 23 Jan 2018 23:35:48 +0000 In-Reply-To: <20180115123351.309626066@linuxfoundation.org> References: <20180115123349.252309699@linuxfoundation.org> <20180115123351.309626066@linuxfoundation.org> Organization: Codethink Ltd. Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 same for snd_pcm_oss_read1(). Ben. -- Ben Hutchings Software Developer, Codethink Ltd.