Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751166AbdFTQmo (ORCPT ); Tue, 20 Jun 2017 12:42:44 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:47542 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751075AbdFTQmn (ORCPT ); Tue, 20 Jun 2017 12:42:43 -0400 Subject: Re: [PATCH v4 12/18] xen/pvcalls: implement poll command To: Stefano Stabellini , xen-devel@lists.xen.org References: <1497553787-3709-1-git-send-email-sstabellini@kernel.org> <1497553787-3709-12-git-send-email-sstabellini@kernel.org> Cc: linux-kernel@vger.kernel.org, jgross@suse.com, Stefano Stabellini From: Boris Ostrovsky Message-ID: <15ea89f6-d46e-2495-1b52-d7290b47c478@oracle.com> Date: Tue, 20 Jun 2017 12:43:31 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1497553787-3709-12-git-send-email-sstabellini@kernel.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1381 Lines: 51 > @@ -499,6 +521,55 @@ static int pvcalls_back_accept(struct xenbus_device *dev, > static int pvcalls_back_poll(struct xenbus_device *dev, > struct xen_pvcalls_request *req) > { > + struct pvcalls_fedata *fedata; > + struct sockpass_mapping *mappass; > + struct xen_pvcalls_response *rsp; > + struct inet_connection_sock *icsk; > + struct request_sock_queue *queue; > + unsigned long flags; > + int ret; > + bool data; > + > + fedata = dev_get_drvdata(&dev->dev); > + > + mappass = radix_tree_lookup(&fedata->socketpass_mappings, req->u.poll.id); > + if (mappass == NULL) > + return -EINVAL; > + > + /* > + * Limitation of the current implementation: only support one > + * concurrent accept or poll call on one socket. > + */ > + spin_lock_irqsave(&mappass->copy_lock, flags); > + if (mappass->reqcopy.cmd != 0) { > + ret = -EINTR; > + goto out; > + } > + > + mappass->reqcopy = *req; > + icsk = inet_csk(mappass->sock->sk); > + queue = &icsk->icsk_accept_queue; > + spin_lock(&queue->rskq_lock); > + data = queue->rskq_accept_head != NULL; > + spin_unlock(&queue->rskq_lock); What is the purpose of the queue lock here? -boris > + if (data) { > + mappass->reqcopy.cmd = 0; > + ret = 0; > + goto out; > + } > + spin_unlock_irqrestore(&mappass->copy_lock, flags); > + > + /* Tell the caller we don't need to send back a notification yet */ > + return -1; >