aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2019-04-11 15:16:52 -0400
committerTrond Myklebust <trond.myklebust@hammerspace.com>2019-04-11 15:41:14 -0400
commitaf6b61d7ef58099c82d854395a0e002be6bd036c (patch)
tree870be0f84564dbbc5ae82534bb6d98a2054ce865
parent0769663b4f580566ef6cdf366f3073dbe8022c39 (diff)
Revert "SUNRPC: Micro-optimise when the task is known not to be sleeping"
This reverts commit 009a82f6437490c262584d65a14094a818bcb747. The ability to optimise here relies on compiler being able to optimise away tail calls to avoid stack overflows. Unfortunately, we are seeing reports of problems, so let's just revert. Reported-by: Daniel Mack <daniel@zonque.org> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
-rw-r--r--include/linux/sunrpc/sched.h8
-rw-r--r--net/sunrpc/clnt.c45
2 files changed, 8 insertions, 45 deletions
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index ec861cd0cfe8..52d41d0c1ae1 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -304,12 +304,4 @@ rpc_clnt_swap_deactivate(struct rpc_clnt *clnt)
304} 304}
305#endif /* CONFIG_SUNRPC_SWAP */ 305#endif /* CONFIG_SUNRPC_SWAP */
306 306
307static inline bool
308rpc_task_need_resched(const struct rpc_task *task)
309{
310 if (RPC_IS_QUEUED(task) || task->tk_callback)
311 return true;
312 return false;
313}
314
315#endif /* _LINUX_SUNRPC_SCHED_H_ */ 307#endif /* _LINUX_SUNRPC_SCHED_H_ */
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 187d10443a15..1d0395ef62c9 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -1540,7 +1540,6 @@ call_start(struct rpc_task *task)
1540 clnt->cl_stats->rpccnt++; 1540 clnt->cl_stats->rpccnt++;
1541 task->tk_action = call_reserve; 1541 task->tk_action = call_reserve;
1542 rpc_task_set_transport(task, clnt); 1542 rpc_task_set_transport(task, clnt);
1543 call_reserve(task);
1544} 1543}
1545 1544
1546/* 1545/*
@@ -1554,9 +1553,6 @@ call_reserve(struct rpc_task *task)
1554 task->tk_status = 0; 1553 task->tk_status = 0;
1555 task->tk_action = call_reserveresult; 1554 task->tk_action = call_reserveresult;
1556 xprt_reserve(task); 1555 xprt_reserve(task);
1557 if (rpc_task_need_resched(task))
1558 return;
1559 call_reserveresult(task);
1560} 1556}
1561 1557
1562static void call_retry_reserve(struct rpc_task *task); 1558static void call_retry_reserve(struct rpc_task *task);
@@ -1579,7 +1575,6 @@ call_reserveresult(struct rpc_task *task)
1579 if (status >= 0) { 1575 if (status >= 0) {
1580 if (task->tk_rqstp) { 1576 if (task->tk_rqstp) {
1581 task->tk_action = call_refresh; 1577 task->tk_action = call_refresh;
1582 call_refresh(task);
1583 return; 1578 return;
1584 } 1579 }
1585 1580
@@ -1605,7 +1600,6 @@ call_reserveresult(struct rpc_task *task)
1605 /* fall through */ 1600 /* fall through */
1606 case -EAGAIN: /* woken up; retry */ 1601 case -EAGAIN: /* woken up; retry */
1607 task->tk_action = call_retry_reserve; 1602 task->tk_action = call_retry_reserve;
1608 call_retry_reserve(task);
1609 return; 1603 return;
1610 case -EIO: /* probably a shutdown */ 1604 case -EIO: /* probably a shutdown */
1611 break; 1605 break;
@@ -1628,9 +1622,6 @@ call_retry_reserve(struct rpc_task *task)
1628 task->tk_status = 0; 1622 task->tk_status = 0;
1629 task->tk_action = call_reserveresult; 1623 task->tk_action = call_reserveresult;
1630 xprt_retry_reserve(task); 1624 xprt_retry_reserve(task);
1631 if (rpc_task_need_resched(task))
1632 return;
1633 call_reserveresult(task);
1634} 1625}
1635 1626
1636/* 1627/*
@@ -1645,9 +1636,6 @@ call_refresh(struct rpc_task *task)
1645 task->tk_status = 0; 1636 task->tk_status = 0;
1646 task->tk_client->cl_stats->rpcauthrefresh++; 1637 task->tk_client->cl_stats->rpcauthrefresh++;
1647 rpcauth_refreshcred(task); 1638 rpcauth_refreshcred(task);
1648 if (rpc_task_need_resched(task))
1649 return;
1650 call_refreshresult(task);
1651} 1639}
1652 1640
1653/* 1641/*
@@ -1666,7 +1654,6 @@ call_refreshresult(struct rpc_task *task)
1666 case 0: 1654 case 0:
1667 if (rpcauth_uptodatecred(task)) { 1655 if (rpcauth_uptodatecred(task)) {
1668 task->tk_action = call_allocate; 1656 task->tk_action = call_allocate;
1669 call_allocate(task);
1670 return; 1657 return;
1671 } 1658 }
1672 /* Use rate-limiting and a max number of retries if refresh 1659 /* Use rate-limiting and a max number of retries if refresh
@@ -1685,7 +1672,6 @@ call_refreshresult(struct rpc_task *task)
1685 task->tk_cred_retry--; 1672 task->tk_cred_retry--;
1686 dprintk("RPC: %5u %s: retry refresh creds\n", 1673 dprintk("RPC: %5u %s: retry refresh creds\n",
1687 task->tk_pid, __func__); 1674 task->tk_pid, __func__);
1688 call_refresh(task);
1689 return; 1675 return;
1690 } 1676 }
1691 dprintk("RPC: %5u %s: refresh creds failed with error %d\n", 1677 dprintk("RPC: %5u %s: refresh creds failed with error %d\n",
@@ -1711,10 +1697,8 @@ call_allocate(struct rpc_task *task)
1711 task->tk_status = 0; 1697 task->tk_status = 0;
1712 task->tk_action = call_encode; 1698 task->tk_action = call_encode;
1713 1699
1714 if (req->rq_buffer) { 1700 if (req->rq_buffer)
1715 call_encode(task);
1716 return; 1701 return;
1717 }
1718 1702
1719 if (proc->p_proc != 0) { 1703 if (proc->p_proc != 0) {
1720 BUG_ON(proc->p_arglen == 0); 1704 BUG_ON(proc->p_arglen == 0);
@@ -1740,12 +1724,8 @@ call_allocate(struct rpc_task *task)
1740 1724
1741 status = xprt->ops->buf_alloc(task); 1725 status = xprt->ops->buf_alloc(task);
1742 xprt_inject_disconnect(xprt); 1726 xprt_inject_disconnect(xprt);
1743 if (status == 0) { 1727 if (status == 0)
1744 if (rpc_task_need_resched(task))
1745 return;
1746 call_encode(task);
1747 return; 1728 return;
1748 }
1749 if (status != -ENOMEM) { 1729 if (status != -ENOMEM) {
1750 rpc_exit(task, status); 1730 rpc_exit(task, status);
1751 return; 1731 return;
@@ -1828,8 +1808,12 @@ call_encode(struct rpc_task *task)
1828 xprt_request_enqueue_receive(task); 1808 xprt_request_enqueue_receive(task);
1829 xprt_request_enqueue_transmit(task); 1809 xprt_request_enqueue_transmit(task);
1830out: 1810out:
1831 task->tk_action = call_bind; 1811 task->tk_action = call_transmit;
1832 call_bind(task); 1812 /* Check that the connection is OK */
1813 if (!xprt_bound(task->tk_xprt))
1814 task->tk_action = call_bind;
1815 else if (!xprt_connected(task->tk_xprt))
1816 task->tk_action = call_connect;
1833} 1817}
1834 1818
1835/* 1819/*
@@ -1847,7 +1831,6 @@ rpc_task_handle_transmitted(struct rpc_task *task)
1847{ 1831{
1848 xprt_end_transmit(task); 1832 xprt_end_transmit(task);
1849 task->tk_action = call_transmit_status; 1833 task->tk_action = call_transmit_status;
1850 call_transmit_status(task);
1851} 1834}
1852 1835
1853/* 1836/*
@@ -1865,7 +1848,6 @@ call_bind(struct rpc_task *task)
1865 1848
1866 if (xprt_bound(xprt)) { 1849 if (xprt_bound(xprt)) {
1867 task->tk_action = call_connect; 1850 task->tk_action = call_connect;
1868 call_connect(task);
1869 return; 1851 return;
1870 } 1852 }
1871 1853
@@ -1896,7 +1878,6 @@ call_bind_status(struct rpc_task *task)
1896 dprint_status(task); 1878 dprint_status(task);
1897 task->tk_status = 0; 1879 task->tk_status = 0;
1898 task->tk_action = call_connect; 1880 task->tk_action = call_connect;
1899 call_connect(task);
1900 return; 1881 return;
1901 } 1882 }
1902 1883
@@ -1981,7 +1962,6 @@ call_connect(struct rpc_task *task)
1981 1962
1982 if (xprt_connected(xprt)) { 1963 if (xprt_connected(xprt)) {
1983 task->tk_action = call_transmit; 1964 task->tk_action = call_transmit;
1984 call_transmit(task);
1985 return; 1965 return;
1986 } 1966 }
1987 1967
@@ -2051,7 +2031,6 @@ call_connect_status(struct rpc_task *task)
2051 case 0: 2031 case 0:
2052 clnt->cl_stats->netreconn++; 2032 clnt->cl_stats->netreconn++;
2053 task->tk_action = call_transmit; 2033 task->tk_action = call_transmit;
2054 call_transmit(task);
2055 return; 2034 return;
2056 } 2035 }
2057 rpc_exit(task, status); 2036 rpc_exit(task, status);
@@ -2087,9 +2066,6 @@ call_transmit(struct rpc_task *task)
2087 xprt_transmit(task); 2066 xprt_transmit(task);
2088 } 2067 }
2089 xprt_end_transmit(task); 2068 xprt_end_transmit(task);
2090 if (rpc_task_need_resched(task))
2091 return;
2092 call_transmit_status(task);
2093} 2069}
2094 2070
2095/* 2071/*
@@ -2107,9 +2083,6 @@ call_transmit_status(struct rpc_task *task)
2107 if (rpc_task_transmitted(task)) { 2083 if (rpc_task_transmitted(task)) {
2108 if (task->tk_status == 0) 2084 if (task->tk_status == 0)
2109 xprt_request_wait_receive(task); 2085 xprt_request_wait_receive(task);
2110 if (rpc_task_need_resched(task))
2111 return;
2112 call_status(task);
2113 return; 2086 return;
2114 } 2087 }
2115 2088
@@ -2170,7 +2143,6 @@ call_bc_encode(struct rpc_task *task)
2170{ 2143{
2171 xprt_request_enqueue_transmit(task); 2144 xprt_request_enqueue_transmit(task);
2172 task->tk_action = call_bc_transmit; 2145 task->tk_action = call_bc_transmit;
2173 call_bc_transmit(task);
2174} 2146}
2175 2147
2176/* 2148/*
@@ -2261,7 +2233,6 @@ call_status(struct rpc_task *task)
2261 status = task->tk_status; 2233 status = task->tk_status;
2262 if (status >= 0) { 2234 if (status >= 0) {
2263 task->tk_action = call_decode; 2235 task->tk_action = call_decode;
2264 call_decode(task);
2265 return; 2236 return;
2266 } 2237 }
2267 2238