Message ID | 20240131215347.1808751-1-cmllamas@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-47214-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp47193dyc; Wed, 31 Jan 2024 13:57:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVigwgmlT+x+J6+s0exscgwMdbNASG8MJ2Jk+zvnTc6dQ0kSka5nCLSZ0+zaes79w/ZLri X-Received: by 2002:a17:906:c348:b0:a28:fe84:f2c6 with SMTP id ci8-20020a170906c34800b00a28fe84f2c6mr1846242ejb.15.1706738229964; Wed, 31 Jan 2024 13:57:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706738229; cv=pass; d=google.com; s=arc-20160816; b=Aufoyk2N3FdDFvTvtCnTu1XlxOpMiUev8owOZko5ea6XIKL70cf3ahaQYvTqbWS0Fi B5LJj21+vqtZ96bgVcHzr9gDFNqpDvVodn33wjKrqWdLXdlYbQ46Qj2TY6SBKUsFt9o4 EUdXRTowbPHEtpo3fV8D+6KKwoSDsBuMHjMlV4B/4Y1Vr0HBTpBZC4+CuGYykJLnx4IJ yHRgiaMmeGAj/JuddrbkDipTK3m0JTqKVtWnxWWUvXM44ybb7/JB26cIGB8T+pl4ivb5 ae7iUtbLHBiGn91GsKJ6/v+iVMZ9N3UA5PbK3B198BmujnPvvK6e/a5uSlVs6UIvIk9i A3cQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:dkim-signature; bh=AnAFDV1t3aX3RqRk7DxFRUBw8cn5gMxBfRf2X8ihrDQ=; fh=uQEciubx6XGy5o4WIxu2p9M7+4nrMZmJvw7//KOKRsw=; b=hU0ypykNe6TL5t2KsePv8Kgo++3XiQri2pWpF/zdS3XijQV68qVR5LKEVcDsaYs19c KUANNMSTMfpHEg/Snps3b39Bl70vIVswwSfFGue0DXw9PzMliwA8Ja34MavP+IC1Fqjy ecfvmRdMndjkgfNoJ671Yp6dpP6cvwlr76IpoFOBfSBD3TWFpCcUKYBRIpJf6BEiRzat MgakyoHBGfH7uFGA0kEAeFwXLb2omYrjCtPv80xNLgJm410EeWxCUhj88KZXtVY3hqSk GDFbMcDBmU9KZErZBubDubXRCISL31hR5XtRSrC/qiaR2y301139ZUscCSGCb7mWWdv7 vysQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ts7Dp+dE; arc=pass (i=1 spf=pass spfdomain=flex--cmllamas.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-47214-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47214-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCV5ZV+nbwrsrWD8BYugklETe4MpGJ2GFlonudKIOonve9Q/7SzndcLE4SVFRVnuZzIL5gKPFzCTJChrtMxB39EuVkomUw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q19-20020a170906771300b00a2d224dd5f1si5972473ejm.417.2024.01.31.13.57.09 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 13:57:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47214-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ts7Dp+dE; arc=pass (i=1 spf=pass spfdomain=flex--cmllamas.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-47214-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47214-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1A0641F28B2A for <ouuuleilei@gmail.com>; Wed, 31 Jan 2024 21:56:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E42E39FD4; Wed, 31 Jan 2024 21:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ts7Dp+dE" Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 146D839AF0 for <linux-kernel@vger.kernel.org>; Wed, 31 Jan 2024 21:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706738034; cv=none; b=Ka6IQPFboOPCMQ4cqdy9kLsC037yZLGCLEX6zenU6X1UZgTMU9RqGpc7BscnjCRztnB3HqTFb0N5ee/XDWvDHnIJVbN4WFPCwNVnEZ0ADn2hBUWutbuJsomILVvA99q2xJsURZ4eAO9YD+ZecnIgrJZJdkaMOTvi2LTDCCalOnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706738034; c=relaxed/simple; bh=4xLkjEkNsl/vSzQQL56AarzQ/fTqiFXmSV0hiQdMmlk=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=St6Mtq1yusDQ7PU7+ZYiCBVsplk6Al1OFaZmkkikcJSgDv+vB58DH8MjotfXD9G9M42e7aTZ5Ua8bjHzCRxQXrYLZcwiYvpzeV7Rd5aoDhj0h8aO8dc92bRYFh4r/fQ3ZbOnIFkVqU6RM8SL7azWgYex2cj0Ck7xg61HCkbZUpk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--cmllamas.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ts7Dp+dE; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--cmllamas.bounces.google.com Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-5cec090b2bdso284537a12.0 for <linux-kernel@vger.kernel.org>; Wed, 31 Jan 2024 13:53:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706738032; x=1707342832; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=AnAFDV1t3aX3RqRk7DxFRUBw8cn5gMxBfRf2X8ihrDQ=; b=ts7Dp+dEbWqxSHWt3fm+nmu7jkU4nnsqztFMCRfiJ1+VDtrh1TGu/9f4BAt+BTuJfR tfdarsz1Gr2RZ4bbH8yoRSNoxKLOqz0XzwEmpALjOHHg6lhDR/HMR1w9q9bphBFdWdFO H+AuEdPA0ZWdVEVTNUN4LwFNDBlOTH+jpfmMFxDd38rNsFkq0tEWl4kKDoCIXJHETA+Q axfBK+z7jhOIp/QBKGcumzrkxGPadja3c9+xI11Shf279v60pkNcmwyi4UbM3BEorqhD +kxgCst6bTAvbOi2pcY52txZN4qGOpCvl2CBZGmdhXGhUFek2VIPNC+d7CGR8jY+JTiG ZKMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706738032; x=1707342832; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AnAFDV1t3aX3RqRk7DxFRUBw8cn5gMxBfRf2X8ihrDQ=; b=heMhG9XTHgU2IRajVEc32oeviCdxxkiksavmkNnjft0Q/hdQNGWJWbkapDvi8WJlps 4nXd1ff3I6am2W5r9/s3mNWP946dSYryVVcHFJ+Ri7gRt3u3IiJ9w+XDMnh5fwtY5Xns S1CEAX15klRlN7gA1PjChSVpsvfWyUqTi5WXlUav4LM6C3a5CENyKvcJa0aSYSGzoi0N 41szQJpoJT1zY/0HHSrPS8AnA8RRSVzi9X4IszZcvrRNY137vBo6DnLfLhgruloRTAjF JdcmOs3kXh6wBuwjfBFw/fqWnp+63xrOiIxpW5xWBijQnfEYMVMxvBKa/QfKVSPy9qRa xZVA== X-Gm-Message-State: AOJu0YxMP29XsdAGbGoQ0S7eNxZ4G99ZS9K9QVY4kpLWoRLBrxsdxQ9r bLBhBqVf+PnNMXCfY4KhO4vq8ERLpRHKkFfeiMo5e7MCvif/3I/HAY+v6Y4l+TcbLDLExH5l086 Na1rOiUtHZg== X-Received: from xllamas.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5070]) (user=cmllamas job=sendgmr) by 2002:a65:68c5:0:b0:5d8:51e2:c8ca with SMTP id k5-20020a6568c5000000b005d851e2c8camr636pgt.2.1706738032095; Wed, 31 Jan 2024 13:53:52 -0800 (PST) Date: Wed, 31 Jan 2024 21:53:46 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Message-ID: <20240131215347.1808751-1-cmllamas@google.com> Subject: [PATCH] binder: signal epoll threads of self-work From: Carlos Llamas <cmllamas@google.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, " =?utf-8?q?Arve_Hj?= =?utf-8?q?=C3=B8nnev=C3=A5g?= " <arve@android.com>, Todd Kjos <tkjos@android.com>, Martijn Coenen <maco@android.com>, Joel Fernandes <joel@joelfernandes.org>, Christian Brauner <brauner@kernel.org>, Carlos Llamas <cmllamas@google.com>, Suren Baghdasaryan <surenb@google.com>, Brian Swetland <swetland@google.com> Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, Alice Ryhl <aliceryhl@google.com>, Steven Moreland <smoreland@google.com>, stable@vger.kernel.org, Greg Kroah-Hartman <gregkh@suse.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789644746358154107 X-GMAIL-MSGID: 1789644746358154107 |
Series |
binder: signal epoll threads of self-work
|
|
Commit Message
Carlos Llamas
Jan. 31, 2024, 9:53 p.m. UTC
In (e)poll mode, threads often depend on I/O events to determine when
data is ready for consumption. Within binder, a thread may initiate a
command via BINDER_WRITE_READ without a read buffer and then make use
of epoll_wait() or similar to consume any responses afterwards.
It is then crucial that epoll threads are signaled via wakeup when they
queue their own work. Otherwise, they risk waiting indefinitely for an
event leaving their work unhandled. What is worse, subsequent commands
won't trigger a wakeup either as the thread has pending work.
Fixes: 457b9a6f09f0 ("Staging: android: add binder driver")
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Martijn Coenen <maco@android.com>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Steven Moreland <smoreland@google.com>
Cc: <stable@vger.kernel.org> # v4.19+
Signed-off-by: Carlos Llamas <cmllamas@google.com>
---
drivers/android/binder.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 8dd23b19e997..eca24f41556d 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -478,6 +478,16 @@ binder_enqueue_thread_work_ilocked(struct binder_thread *thread, { WARN_ON(!list_empty(&thread->waiting_thread_node)); binder_enqueue_work_ilocked(work, &thread->todo); + + /* (e)poll-based threads require an explicit wakeup signal when + * queuing their own work; they rely on these events to consume + * messages without I/O block. Without it, threads risk waiting + * indefinitely without handling the work. + */ + if (thread->looper & BINDER_LOOPER_STATE_POLL && + thread->pid == current->pid && !thread->process_todo) + wake_up_interruptible_sync(&thread->wait); + thread->process_todo = true; }