Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp27724imm; Thu, 30 Aug 2018 13:27:29 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda2GFvJtDdQGPC2fcN1GSBzjL/BBAH+goCMRLPPVk0VdofUpF3kB6r2qCrevFLRu0yrQFZX X-Received: by 2002:a63:a54f:: with SMTP id r15-v6mr11147780pgu.336.1535660849492; Thu, 30 Aug 2018 13:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535660849; cv=none; d=google.com; s=arc-20160816; b=uSATV3HeDyPh6IqwXKViPqMLHJNy1NxKyHEwX0uS890bzN+K6V8wQCC/YonJso3rtl kt58er3OQlXq0HmQy3rhICstYjcER0H5+Cy2Z6mrDaDSZu5JQe6pzqqjIPM4CpWcEXDc oHPC31h/RzhBQdidhzVyuVs5zKHQSXgHlT2gVH1XCbzJqRY3BS5TxN5kI9rl4abihlqt g+immYQ/tGQ5fdXyTw3ihxa9N2nOq7J2AgnfCkVKmGefUS15Qe5jA1Jy74I49BmaOb0X 3AQTBrMgNuYjaFUbnEbDf27X5Z8+EhGyOqA3JxI6x8ra0D7KanRJSYkP8e5AunGVJWGR eLog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=iuQ5spCkYBImoJ5Jc7VISLxVqEoNMIE4pA4GRSdBhrA=; b=tKJh9IRBJT18+lpHYPAsV9C88f7dRokpCvQ0VXCgy6yqJnN7T5+biwbo7Rx7fGze// /Gobvfp0z/EIpWTnrNhPZvkARRKC6Vuz58nBj4oWnVqVOu3MOk1dtvaF2ObpZWe0uXGi Kkvzrg4J0luRrpS9nwCRX+P/ealO7I+z++bodJVSYOa+VmyfGneD0fFBvK2xuQQDMKP6 EjOxH2YGapLbSmE8ZFGzsDJJQEs05oQCuSe7ogAwcIb9e5nZojQedXrhHAYH2+RNH/WK uYu0OamRyPedoswaYpPS7v8QUCZ5Bqc4mwByfw63c3aRQQYvoF/KQEoKNiATTiZPzoGD zhYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=y93v5HyO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e94-v6si7407508plb.435.2018.08.30.13.27.13; Thu, 30 Aug 2018 13:27:29 -0700 (PDT) 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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=y93v5HyO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727368AbeHaA26 (ORCPT + 99 others); Thu, 30 Aug 2018 20:28:58 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:58672 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727173AbeHaA26 (ORCPT ); Thu, 30 Aug 2018 20:28:58 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7UKNY4v031676; Thu, 30 Aug 2018 20:24:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=iuQ5spCkYBImoJ5Jc7VISLxVqEoNMIE4pA4GRSdBhrA=; b=y93v5HyONyvRswYshGZ5gRH5OBFYZnbcY+6SGgVDj5w8Rkncd1voYGsjvoYQjg57xhkr xxWudFPsqNzFEshCfh/Ji+UFmqA6Kr9ySkU34oPkALjuQtGgNU2rHfvMH5wmWVzUaaRG AVLHholxd7OdJO19T7hxr0FrU5cthfNnPwaZM8Rzmu65xy+QZfSWyRHw7I6WdF+mYpSr DMUqc0iDJSOhtZvSjB11dugwpy5jbtOf9zSVvOOTULsw+os+aKsPQY6vMF+Ysxu+BLTB K8gwScu5FBykmz7V3RGHgIj4RPALLMDLLAFYwFklpHsNXKLz1Cqz8VH7S2v15ELALJJP Rw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2m2yrqptsq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Aug 2018 20:24:44 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w7UKOhiZ031465 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Aug 2018 20:24:44 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7UKOh6O005595; Thu, 30 Aug 2018 20:24:43 GMT Received: from smazumda-Precision-T1600.us.oracle.com (/10.132.91.175) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Aug 2018 13:24:43 -0700 From: subhra mazumdar To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, dhaval.giani@oracle.com, steven.sistare@oracle.com, subhra.mazumdar@oracle.com Subject: [RFC PATCH 1/2] pipe: introduce busy wait for pipe Date: Thu, 30 Aug 2018 13:24:57 -0700 Message-Id: <20180830202458.32579-2-subhra.mazumdar@oracle.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20180830202458.32579-1-subhra.mazumdar@oracle.com> References: <20180830202458.32579-1-subhra.mazumdar@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9001 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=855 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808300206 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce pipe_ll_usec field for pipes that indicates the amount of micro seconds a thread should spin if pipe is empty or full before sleeping. This is similar to network sockets. Workloads like hackbench in pipe mode benefits significantly from this by avoiding the sleep and wakeup overhead. Other similar usecases can benefit. pipe_wait_flag is used to signal any thread busy waiting. pipe_busy_loop_timeout checks if spin time is over. Signed-off-by: subhra mazumdar --- include/linux/pipe_fs_i.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h index e7497c9..fdfd2a2 100644 --- a/include/linux/pipe_fs_i.h +++ b/include/linux/pipe_fs_i.h @@ -1,6 +1,8 @@ #ifndef _LINUX_PIPE_FS_I_H #define _LINUX_PIPE_FS_I_H +#include + #define PIPE_DEF_BUFFERS 16 #define PIPE_BUF_FLAG_LRU 0x01 /* page is on the LRU */ @@ -54,6 +56,8 @@ struct pipe_inode_info { unsigned int waiting_writers; unsigned int r_counter; unsigned int w_counter; + unsigned int pipe_ll_usec; + unsigned long pipe_wait_flag; struct page *tmp_page; struct fasync_struct *fasync_readers; struct fasync_struct *fasync_writers; @@ -157,6 +161,21 @@ static inline int pipe_buf_steal(struct pipe_inode_info *pipe, return buf->ops->steal(pipe, buf); } +static inline unsigned long pipe_busy_loop_current_time(void) +{ + return (unsigned long)(local_clock() >> 10); +} + +static inline bool pipe_busy_loop_timeout(struct pipe_inode_info *pipe, + unsigned long start_time) +{ + unsigned long bp_usec = READ_ONCE(pipe->pipe_ll_usec); + unsigned long end_time = start_time + bp_usec; + unsigned long now = pipe_busy_loop_current_time(); + + return time_after(now, end_time); +} + /* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual memory allocation, whereas PIPE_BUF makes atomicity guarantees. */ #define PIPE_SIZE PAGE_SIZE -- 2.9.3