Re: [Devel] [PATCH] scsi/eh: fix hang adding ehandler wakeups after decrementing host_busy

2017-11-08 Thread Stuart Hayes

Are there any issues with this patch 
(https://patchwork.kernel.org/patch/9938919/) that Pavel Tikhomirov submitted 
back in September?  I am willing to help if there's anything I can do to help 
get it accepted.

The failing case I'm working on involves lots of servers with disk read/write 
activity with periodic INQUIRY commands that aren't supported by the target 
device, so the error handler gets invoked periodically, and some of the systems 
will hang after a day or two.

Thanks
Stuart

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH v5 2/2] nfs: protect callback execution against per-net callback thread shutdown

2017-11-08 Thread Stanislav Kinsburskiy
From: Stanislav Kinsburskiy 

Here is the race:

CPU #0  CPU#1

cleanup_mnt nfs41_callback_svc (get xprt from the list)
nfs_callback_down   ...
... ...
svc_close_net   ...
... ...
svc_xprt_free   ...
svc_bc_sock_freebc_svc_process
kfree(xprt) svc_process_common
rqstp->rq_xprt->xpt_ops (use after free)

The problem is that per-net SUNRPC transports shutdown is done regardless
current callback execution. This is a race leading to transport use-after-free
in callback handler.
This patch fixes it in stright-forward way. I.e. it protects callback
execution with the same mutex used for per-net data creation and destruction.
Hopefully, it won't slow down NFS client significantly.

https://jira.sw.ru/browse/PSBM-75751

v5: destroy all per-net backchannel requests before transports on in
nfs_callback_down_net

v4: use another mutex to protect callback execution agains per-net transports
shutdown.
This guarantees, that transports won't be destroyed by shutdown callback while
execution is in progress and vice versa.

v3: Fix mutex deadlock, when shutdown callback waits for thread to exit (with
mutex taken), while thread wait for the mutex to take.
The idea is to simply check if thread has to exit, if mutex lock has failed.
This is a busy loop, but it shouldn't happend often and for long.

Signed-off-by: Stanislav Kinsburskiy 
---
 fs/nfs/callback.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index 0beb275..e18d774 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -99,6 +99,8 @@ nfs4_callback_up(struct svc_serv *serv)
 }
 
 #if defined(CONFIG_NFS_V4_1)
+static DEFINE_MUTEX(nfs41_callback_mutex);
+
 /*
  * The callback service for NFSv4.1 callbacks
  */
@@ -117,6 +119,12 @@ nfs41_callback_svc(void *vrqstp)
if (try_to_freeze())
continue;
 
+   mutex_lock(&nfs41_callback_mutex);
+   if (kthread_should_stop()) {
+   mutex_unlock(&nfs41_callback_mutex);
+   return 0;
+   }
+
prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE);
spin_lock_bh(&serv->sv_cb_lock);
if (!list_empty(&serv->sv_cb_list)) {
@@ -129,8 +137,10 @@ nfs41_callback_svc(void *vrqstp)
error = bc_svc_process(serv, req, rqstp);
dprintk("bc_svc_process() returned w/ error code= %d\n",
error);
+   mutex_unlock(&nfs41_callback_mutex);
} else {
spin_unlock_bh(&serv->sv_cb_lock);
+   mutex_unlock(&nfs41_callback_mutex);
schedule();
finish_wait(&serv->sv_cb_waitq, &wq);
}
@@ -242,6 +252,7 @@ static void nfs_callback_down_net(u32 minorversion, struct 
svc_serv *serv, struc
return;
 
dprintk("NFS: destroy per-net callback data; net=%p\n", net);
+   bc_svc_flush_queue_net(serv, net);
svc_shutdown_net(serv, net);
 }
 
@@ -377,7 +388,13 @@ void nfs_callback_down(int minorversion, struct net *net)
struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
 
mutex_lock(&nfs_callback_mutex);
+#if defined(CONFIG_NFS_V4_1)
+   mutex_lock(&nfs41_callback_mutex);
+   nfs_callback_down_net(minorversion, cb_info->serv, net);
+   mutex_unlock(&nfs41_callback_mutex);
+#else
nfs_callback_down_net(minorversion, cb_info->serv, net);
+#endif
cb_info->users--;
if (cb_info->users == 0 && cb_info->task != NULL) {
kthread_stop(cb_info->task);

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH v5 0/2] nfs: fix race between callback shutdown and execution

2017-11-08 Thread Stanislav Kinsburskiy
The idea is to use mutex for protecting callback execution agains per-net
callback shutdown and destroying all the net-related backchannel requests
before transports destruction.


---

Stanislav Kinsburskiy (2):
  sunrpc: bc_svc_flush_queue_net() helper introduced
  nfs: protect callback execution against per-net callback thread shutdown


 fs/nfs/callback.c  |   17 +
 include/linux/sunrpc/svc.h |2 ++
 net/sunrpc/svc.c   |   15 +++
 3 files changed, 34 insertions(+)

--
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH v5 1/2] sunrpc: bc_svc_flush_queue_net() helper introduced

2017-11-08 Thread Stanislav Kinsburskiy
From: Stanislav Kinsburskiy 

This helper can be used to remove backchannel requests from callback queue on
per-net basis.

Signed-off-by: Stanislav Kinsburskiy 
---
 include/linux/sunrpc/svc.h |2 ++
 net/sunrpc/svc.c   |   15 +++
 2 files changed, 17 insertions(+)

diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 2b30868..fe70ff0 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -484,6 +484,8 @@ void   svc_reserve(struct svc_rqst *rqstp, 
int space);
 struct svc_pool *  svc_pool_for_cpu(struct svc_serv *serv, int cpu);
 char *svc_print_addr(struct svc_rqst *, char *, size_t);
 
+void bc_svc_flush_queue_net(struct svc_serv *serv, struct net *net);
+
 #defineRPC_MAX_ADDRBUFLEN  (63U)
 
 /*
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index de8cded..2ca4ff7 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1338,6 +1338,21 @@ svc_process(struct svc_rqst *rqstp)
 EXPORT_SYMBOL_GPL(svc_process);
 
 #if defined(CONFIG_SUNRPC_BACKCHANNEL)
+void bc_svc_flush_queue_net(struct svc_serv *serv, struct net *net)
+{
+   struct rpc_rqst *req, *tmp;
+
+   spin_lock_bh(&serv->sv_cb_lock);
+   list_for_each_entry_safe(req, tmp, &serv->sv_cb_list, rq_bc_list) {
+   if (req->rq_xprt->xprt_net == net) {
+   list_del(&req->rq_bc_list);
+   xprt_free_bc_request(req);
+   }
+   }
+   spin_unlock_bh(&serv->sv_cb_lock);
+}
+EXPORT_SYMBOL_GPL(bc_svc_flush_queue_net);
+
 /*
  * Process a backchannel RPC request that arrived over an existing
  * outbound connection

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH RHEL7 COMMIT] tswap, tcache: Increase shrinkers seeks

2017-11-08 Thread Konstantin Khorenko
The commit is pushed to "branch-rh7-3.10.0-693.1.1.vz7.37.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.1.1.vz7.37.24
-->
commit d6cdd02bdcf3f264f18b1d187cb419ecc5607644
Author: Kirill Tkhai 
Date:   Wed Nov 8 18:28:06 2017 +0300

tswap, tcache: Increase shrinkers seeks

Commit e008b95a28ef95dd4bb08f69c89d26fc5fa7411a
"ms/mm: use sc->priority for slab shrink targets"
exposed the fact we shrinks too many tcache pages.

Shrinkers of {in,}active pages shrink up to 32
pages, while tcache and tswap shrinks 128 pages.
This became a reason of tcache active test fail.

This patch makes numbers of shrinked pages of tcache
and tswap in consistent state with pages shrinkers,
and restores the test-expected behaviour.

https://jira.sw.ru/browse/PSBM-72584

Signed-off-by: Kirill Tkhai 
Acked-by: Andrey Ryabinin 
---
 mm/tcache.c | 2 +-
 mm/tswap.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/tcache.c b/mm/tcache.c
index d1a2c53..8b893e6 100644
--- a/mm/tcache.c
+++ b/mm/tcache.c
@@ -1202,7 +1202,7 @@ static unsigned long tcache_shrink_scan(struct shrinker 
*shrink,
 struct shrinker tcache_shrinker = {
.count_objects  = tcache_shrink_count,
.scan_objects   = tcache_shrink_scan,
-   .seeks  = 1,
+   .seeks  = 4,
.batch  = TCACHE_SCAN_BATCH,
.flags  = SHRINKER_NUMA_AWARE,
 };
diff --git a/mm/tswap.c b/mm/tswap.c
index 38a389f..b7a990e 100644
--- a/mm/tswap.c
+++ b/mm/tswap.c
@@ -271,7 +271,7 @@ static unsigned long tswap_shrink_scan(struct shrinker 
*shrink,
 static struct shrinker tswap_shrinker = {
.count_objects = tswap_shrink_count,
.scan_objects = tswap_shrink_scan,
-   .seeks = 1,
+   .seeks = 4,
.flags = SHRINKER_NUMA_AWARE,
 };
 
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


Re: [Devel] [PATCH v4] nfs: protect callback execution against per-net callback thread shutdown

2017-11-08 Thread Kirill Tkhai
On 08.11.2017 17:07, Stanislav Kinsburskiy wrote:
> From: Stanislav Kinsburskiy 
> 
> Here is the race:
> 
> CPU #0CPU#1
> 
> cleanup_mnt   nfs41_callback_svc (get xprt from the list)
> nfs_callback_down ...
> ...   ...
> svc_close_net ...
> ...   ...
> svc_xprt_free ...
> svc_bc_sock_free  bc_svc_process
> kfree(xprt)   svc_process_common
>   rqstp->rq_xprt->xpt_ops (use after free)
> 
> The problem is that per-net SUNRPC transports shutdown is done regardless
> current callback execution. This is a race leading to transport use-after-free
> in callback handler.
> This patch fixes it in stright-forward way. I.e. it protects callback
> execution with the same mutex used for per-net data creation and destruction.
> Hopefully, it won't slow down NFS client significantly.
> 
> https://jira.sw.ru/browse/PSBM-75751
> 
> v4: use another mutex to protect callback execution agains per-net transports
> shutdown.
> This guarantees, that transports won't be destroyed by shutdown callback while
> execution is in progress and vice versa.
> 
> v3: Fix mutex deadlock, when shutdown callback waits for thread to exit (with
> mutex taken), while thread wait for the mutex to take.
> The idea is to simply check if thread has to exit, if mutex lock has failed.
> This is a busy loop, but it shouldn't happend often and for long.
> 
> Signed-off-by: Stanislav Kinsburskiy 
> ---
>  fs/nfs/callback.c |   16 
>  1 file changed, 16 insertions(+)
> 
> diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
> index 0beb275..4d7979b 100644
> --- a/fs/nfs/callback.c
> +++ b/fs/nfs/callback.c
> @@ -99,6 +99,8 @@ nfs4_callback_up(struct svc_serv *serv)
>  }
>  
>  #if defined(CONFIG_NFS_V4_1)
> +static DEFINE_MUTEX(nfs41_callback_mutex);
> +
>  /*
>   * The callback service for NFSv4.1 callbacks
>   */
> @@ -117,6 +119,12 @@ nfs41_callback_svc(void *vrqstp)
>   if (try_to_freeze())
>   continue;
>  
> + mutex_lock(&nfs41_callback_mutex);
> + if (kthread_should_stop()) {
> + mutex_unlock(&nfs41_callback_mutex);
> + return 0;
> + }
> +
>   prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE);
>   spin_lock_bh(&serv->sv_cb_lock);
>   if (!list_empty(&serv->sv_cb_list)) {
> @@ -129,8 +137,10 @@ nfs41_callback_svc(void *vrqstp)
>   error = bc_svc_process(serv, req, rqstp);
>   dprintk("bc_svc_process() returned w/ error code= %d\n",
>   error);
> + mutex_unlock(&nfs41_callback_mutex);
>   } else {
>   spin_unlock_bh(&serv->sv_cb_lock);
> + mutex_unlock(&nfs41_callback_mutex);
>   schedule();
>   finish_wait(&serv->sv_cb_waitq, &wq);
>   }
> @@ -377,7 +387,13 @@ void nfs_callback_down(int minorversion, struct net *net)
>   struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
>  
>   mutex_lock(&nfs_callback_mutex);
> +#if defined(CONFIG_NFS_V4_1)
> + mutex_lock(&nfs41_callback_mutex);
> + nfs_callback_down_net(minorversion, cb_info->serv, net);
> + mutex_unlock(&nfs41_callback_mutex);

It seems we also should flush queue here.

> +#else
>   nfs_callback_down_net(minorversion, cb_info->serv, net);
> +#endif
>   cb_info->users--;
>   if (cb_info->users == 0 && cb_info->task != NULL) {
>   kthread_stop(cb_info->task);
> 
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


Re: [Devel] [PATCH] nfs: protect callback execution against per-net callback thread shutdown

2017-11-08 Thread Stanislav Kinsburskiy
Please, ignore

08.11.2017 15:07, Stanislav Kinsburskiy пишет:
> From: Stanislav Kinsburskiy 
> 
> Here is the race:
> 
> CPU #0CPU#1
> 
> cleanup_mnt   nfs41_callback_svc (get xprt from the list)
> nfs_callback_down ...
> ...   ...
> svc_close_net ...
> ...   ...
> svc_xprt_free ...
> svc_bc_sock_free  bc_svc_process
> kfree(xprt)   svc_process_common
>   rqstp->rq_xprt->xpt_ops (use after free)
> 
> The problem is that per-net SUNRPC transports shutdown is done regardless
> current callback execution. This is a race leading to transport use-after-free
> in callback handler.
> This patch fixes it in stright-forward way. I.e. it protects callback
> execution with the same mutex used for per-net data creation and destruction.
> Hopefully, it won't slow down NFS client significantly.
> 
> https://jira.sw.ru/browse/PSBM-75751
> 
> v4: use another mutex to protect callback execution agains per-net transports
> shutdown.
> This guarantees, that transports won't be destroyed by shutdown callback while
> execution is in progress and vice versa.
> 
> v3: Fix mutex deadlock, when shutdown callback waits for thread to exit (with
> mutex taken), while thread wait for the mutex to take.
> The idea is to simply check if thread has to exit, if mutex lock has failed.
> This is a busy loop, but it shouldn't happend often and for long.
> 
> Signed-off-by: Stanislav Kinsburskiy 
> ---
>  fs/nfs/callback.c |   16 
>  1 file changed, 16 insertions(+)
> 
> diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
> index 0beb275..4d7979b 100644
> --- a/fs/nfs/callback.c
> +++ b/fs/nfs/callback.c
> @@ -99,6 +99,8 @@ nfs4_callback_up(struct svc_serv *serv)
>  }
>  
>  #if defined(CONFIG_NFS_V4_1)
> +static DEFINE_MUTEX(nfs41_callback_mutex);
> +
>  /*
>   * The callback service for NFSv4.1 callbacks
>   */
> @@ -117,6 +119,12 @@ nfs41_callback_svc(void *vrqstp)
>   if (try_to_freeze())
>   continue;
>  
> + mutex_lock(&nfs41_callback_mutex);
> + if (kthread_should_stop()) {
> + mutex_unlock(&nfs41_callback_mutex);
> + return 0;
> + }
> +
>   prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE);
>   spin_lock_bh(&serv->sv_cb_lock);
>   if (!list_empty(&serv->sv_cb_list)) {
> @@ -129,8 +137,10 @@ nfs41_callback_svc(void *vrqstp)
>   error = bc_svc_process(serv, req, rqstp);
>   dprintk("bc_svc_process() returned w/ error code= %d\n",
>   error);
> + mutex_unlock(&nfs41_callback_mutex);
>   } else {
>   spin_unlock_bh(&serv->sv_cb_lock);
> + mutex_unlock(&nfs41_callback_mutex);
>   schedule();
>   finish_wait(&serv->sv_cb_waitq, &wq);
>   }
> @@ -377,7 +387,13 @@ void nfs_callback_down(int minorversion, struct net *net)
>   struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
>  
>   mutex_lock(&nfs_callback_mutex);
> +#if defined(CONFIG_NFS_V4_1)
> + mutex_lock(&nfs41_callback_mutex);
> + nfs_callback_down_net(minorversion, cb_info->serv, net);
> + mutex_unlock(&nfs41_callback_mutex);
> +#else
>   nfs_callback_down_net(minorversion, cb_info->serv, net);
> +#endif
>   cb_info->users--;
>   if (cb_info->users == 0 && cb_info->task != NULL) {
>   kthread_stop(cb_info->task);
> 
> ___
> Devel mailing list
> Devel@openvz.org
> https://lists.openvz.org/mailman/listinfo/devel
> 
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH] nfs: protect callback execution against per-net callback thread shutdown

2017-11-08 Thread Stanislav Kinsburskiy
From: Stanislav Kinsburskiy 

Here is the race:

CPU #0  CPU#1

cleanup_mnt nfs41_callback_svc (get xprt from the list)
nfs_callback_down   ...
... ...
svc_close_net   ...
... ...
svc_xprt_free   ...
svc_bc_sock_freebc_svc_process
kfree(xprt) svc_process_common
rqstp->rq_xprt->xpt_ops (use after free)

The problem is that per-net SUNRPC transports shutdown is done regardless
current callback execution. This is a race leading to transport use-after-free
in callback handler.
This patch fixes it in stright-forward way. I.e. it protects callback
execution with the same mutex used for per-net data creation and destruction.
Hopefully, it won't slow down NFS client significantly.

https://jira.sw.ru/browse/PSBM-75751

v4: use another mutex to protect callback execution agains per-net transports
shutdown.
This guarantees, that transports won't be destroyed by shutdown callback while
execution is in progress and vice versa.

v3: Fix mutex deadlock, when shutdown callback waits for thread to exit (with
mutex taken), while thread wait for the mutex to take.
The idea is to simply check if thread has to exit, if mutex lock has failed.
This is a busy loop, but it shouldn't happend often and for long.

Signed-off-by: Stanislav Kinsburskiy 
---
 fs/nfs/callback.c |   16 
 1 file changed, 16 insertions(+)

diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index 0beb275..4d7979b 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -99,6 +99,8 @@ nfs4_callback_up(struct svc_serv *serv)
 }
 
 #if defined(CONFIG_NFS_V4_1)
+static DEFINE_MUTEX(nfs41_callback_mutex);
+
 /*
  * The callback service for NFSv4.1 callbacks
  */
@@ -117,6 +119,12 @@ nfs41_callback_svc(void *vrqstp)
if (try_to_freeze())
continue;
 
+   mutex_lock(&nfs41_callback_mutex);
+   if (kthread_should_stop()) {
+   mutex_unlock(&nfs41_callback_mutex);
+   return 0;
+   }
+
prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE);
spin_lock_bh(&serv->sv_cb_lock);
if (!list_empty(&serv->sv_cb_list)) {
@@ -129,8 +137,10 @@ nfs41_callback_svc(void *vrqstp)
error = bc_svc_process(serv, req, rqstp);
dprintk("bc_svc_process() returned w/ error code= %d\n",
error);
+   mutex_unlock(&nfs41_callback_mutex);
} else {
spin_unlock_bh(&serv->sv_cb_lock);
+   mutex_unlock(&nfs41_callback_mutex);
schedule();
finish_wait(&serv->sv_cb_waitq, &wq);
}
@@ -377,7 +387,13 @@ void nfs_callback_down(int minorversion, struct net *net)
struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
 
mutex_lock(&nfs_callback_mutex);
+#if defined(CONFIG_NFS_V4_1)
+   mutex_lock(&nfs41_callback_mutex);
+   nfs_callback_down_net(minorversion, cb_info->serv, net);
+   mutex_unlock(&nfs41_callback_mutex);
+#else
nfs_callback_down_net(minorversion, cb_info->serv, net);
+#endif
cb_info->users--;
if (cb_info->users == 0 && cb_info->task != NULL) {
kthread_stop(cb_info->task);

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH v4] nfs: protect callback execution against per-net callback thread shutdown

2017-11-08 Thread Stanislav Kinsburskiy
From: Stanislav Kinsburskiy 

Here is the race:

CPU #0  CPU#1

cleanup_mnt nfs41_callback_svc (get xprt from the list)
nfs_callback_down   ...
... ...
svc_close_net   ...
... ...
svc_xprt_free   ...
svc_bc_sock_freebc_svc_process
kfree(xprt) svc_process_common
rqstp->rq_xprt->xpt_ops (use after free)

The problem is that per-net SUNRPC transports shutdown is done regardless
current callback execution. This is a race leading to transport use-after-free
in callback handler.
This patch fixes it in stright-forward way. I.e. it protects callback
execution with the same mutex used for per-net data creation and destruction.
Hopefully, it won't slow down NFS client significantly.

https://jira.sw.ru/browse/PSBM-75751

v4: use another mutex to protect callback execution agains per-net transports
shutdown.
This guarantees, that transports won't be destroyed by shutdown callback while
execution is in progress and vice versa.

v3: Fix mutex deadlock, when shutdown callback waits for thread to exit (with
mutex taken), while thread wait for the mutex to take.
The idea is to simply check if thread has to exit, if mutex lock has failed.
This is a busy loop, but it shouldn't happend often and for long.

Signed-off-by: Stanislav Kinsburskiy 
---
 fs/nfs/callback.c |   16 
 1 file changed, 16 insertions(+)

diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index 0beb275..4d7979b 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -99,6 +99,8 @@ nfs4_callback_up(struct svc_serv *serv)
 }
 
 #if defined(CONFIG_NFS_V4_1)
+static DEFINE_MUTEX(nfs41_callback_mutex);
+
 /*
  * The callback service for NFSv4.1 callbacks
  */
@@ -117,6 +119,12 @@ nfs41_callback_svc(void *vrqstp)
if (try_to_freeze())
continue;
 
+   mutex_lock(&nfs41_callback_mutex);
+   if (kthread_should_stop()) {
+   mutex_unlock(&nfs41_callback_mutex);
+   return 0;
+   }
+
prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE);
spin_lock_bh(&serv->sv_cb_lock);
if (!list_empty(&serv->sv_cb_list)) {
@@ -129,8 +137,10 @@ nfs41_callback_svc(void *vrqstp)
error = bc_svc_process(serv, req, rqstp);
dprintk("bc_svc_process() returned w/ error code= %d\n",
error);
+   mutex_unlock(&nfs41_callback_mutex);
} else {
spin_unlock_bh(&serv->sv_cb_lock);
+   mutex_unlock(&nfs41_callback_mutex);
schedule();
finish_wait(&serv->sv_cb_waitq, &wq);
}
@@ -377,7 +387,13 @@ void nfs_callback_down(int minorversion, struct net *net)
struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
 
mutex_lock(&nfs_callback_mutex);
+#if defined(CONFIG_NFS_V4_1)
+   mutex_lock(&nfs41_callback_mutex);
+   nfs_callback_down_net(minorversion, cb_info->serv, net);
+   mutex_unlock(&nfs41_callback_mutex);
+#else
nfs_callback_down_net(minorversion, cb_info->serv, net);
+#endif
cb_info->users--;
if (cb_info->users == 0 && cb_info->task != NULL) {
kthread_stop(cb_info->task);

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


Re: [Devel] [PATCH] tswap, tcache: Increase shrinkers seeks

2017-11-08 Thread Andrey Ryabinin


On 11/08/2017 01:21 PM, Kirill Tkhai wrote:
> Commit e008b95a28ef95dd4bb08f69c89d26fc5fa7411a
> "ms/mm: use sc->priority for slab shrink targets"
> exposed the fact we shrinks too many tcache pages.
> 
> Shrinkers of {in,}active pages shrink up to 32
> pages, while tcache and tswap shrinks 128 pages.
> This became a reason of tcache active test fail.
> 
> This patch makes numbers of shrinked pages of tcache
> and tswap in consistent state with pages shrinkers,
> and restores the test-expected behaviour.
> 
> https://jira.sw.ru/browse/PSBM-72584
> 
> Signed-off-by: Kirill Tkhai 

Acked-by: Andrey Ryabinin 
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH] tswap, tcache: Increase shrinkers seeks

2017-11-08 Thread Kirill Tkhai
Commit e008b95a28ef95dd4bb08f69c89d26fc5fa7411a
"ms/mm: use sc->priority for slab shrink targets"
exposed the fact we shrinks too many tcache pages.

Shrinkers of {in,}active pages shrink up to 32
pages, while tcache and tswap shrinks 128 pages.
This became a reason of tcache active test fail.

This patch makes numbers of shrinked pages of tcache
and tswap in consistent state with pages shrinkers,
and restores the test-expected behaviour.

https://jira.sw.ru/browse/PSBM-72584

Signed-off-by: Kirill Tkhai 
---
 mm/tcache.c |2 +-
 mm/tswap.c  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/tcache.c b/mm/tcache.c
index d1a2c53e11a..8b893e6b520 100644
--- a/mm/tcache.c
+++ b/mm/tcache.c
@@ -1202,7 +1202,7 @@ static unsigned long tcache_shrink_scan(struct shrinker 
*shrink,
 struct shrinker tcache_shrinker = {
.count_objects  = tcache_shrink_count,
.scan_objects   = tcache_shrink_scan,
-   .seeks  = 1,
+   .seeks  = 4,
.batch  = TCACHE_SCAN_BATCH,
.flags  = SHRINKER_NUMA_AWARE,
 };
diff --git a/mm/tswap.c b/mm/tswap.c
index 38a389fb0ca..b7a990e8cd8 100644
--- a/mm/tswap.c
+++ b/mm/tswap.c
@@ -271,7 +271,7 @@ static unsigned long tswap_shrink_scan(struct shrinker 
*shrink,
 static struct shrinker tswap_shrinker = {
.count_objects = tswap_shrink_count,
.scan_objects = tswap_shrink_scan,
-   .seeks = 1,
+   .seeks = 4,
.flags = SHRINKER_NUMA_AWARE,
 };
 

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH] mm: Change formula of calculation of default min_free_kbytes

2017-11-08 Thread Kirill Tkhai
Parameter min_free_kbytes acts on per zone watermarks. It is used
to calculate the zones free memory value, below which the direct
reclaim starts and becomes throttled (the called task sleeps).

This patch makes default min_free_kbytes to be 2% of available
physical memory, but not more than 4GB. And this is more, than
previous formula gave (it was a sqrt). Why do we need that.

We bumped in the situation, when intense disc write inside a CT
on a node, having very few free memory, may lead to the state,
when almost all tasks are spining in direct reclaim. The tasks
can't do effective reclaim as generated dirty pages are written
and released by ploop threads, and thus the tasks in practically
are just busy looping. Ploop threads can't produce the effective
reclaim, as processors are occupied by the busylooping tasks
and also they need free pages to do that. So, the system is
looping and becomes very slow and unresponsible.

https://jira.sw.ru/browse/PSBM-69296

Signed-off-by: Kirill Tkhai 
---
 mm/page_alloc.c |   27 +++
 1 file changed, 3 insertions(+), 24 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 137d1d86ddf..2108034bd80 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6399,27 +6399,6 @@ void setup_per_zone_wmarks(void)
 
 /*
  * Initialise min_free_kbytes.
- *
- * For small machines we want it small (128k min).  For large machines
- * we want it large (64MB max).  But it is not linear, because network
- * bandwidth does not increase linearly with machine size.  We use
- *
- * min_free_kbytes = 4 * sqrt(lowmem_kbytes), for better accuracy:
- * min_free_kbytes = sqrt(lowmem_kbytes * 16)
- *
- * which yields
- *
- * 16MB:   512k
- * 32MB:   724k
- * 64MB:   1024k
- * 128MB:  1448k
- * 256MB:  2048k
- * 512MB:  2896k
- * 1024MB: 4096k
- * 2048MB: 5792k
- * 4096MB: 8192k
- * 8192MB: 11584k
- * 16384MB:16384k
  */
 int __meminit init_per_zone_wmark_min(void)
 {
@@ -6427,14 +6406,14 @@ int __meminit init_per_zone_wmark_min(void)
int new_min_free_kbytes;
 
lowmem_kbytes = nr_free_buffer_pages() * (PAGE_SIZE >> 10);
-   new_min_free_kbytes = int_sqrt(lowmem_kbytes * 16);
+   new_min_free_kbytes = lowmem_kbytes * 2 / 100; /* 2% */
 
if (new_min_free_kbytes > user_min_free_kbytes) {
min_free_kbytes = new_min_free_kbytes;
if (min_free_kbytes < 128)
min_free_kbytes = 128;
-   if (min_free_kbytes > 65536)
-   min_free_kbytes = 65536;
+   if (min_free_kbytes > 4194304)
+   min_free_kbytes = 4194304;
} else {
pr_warn("min_free_kbytes is not updated to %d because user 
defined value %d is preferred\n",
new_min_free_kbytes, user_min_free_kbytes);

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel