4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2010, 2012, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/ldlm/ldlm_pool.c
38 * Author: Yury Umanets <umka@clusterfs.com>
42 * Idea of this code is rather simple. Each second, for each server namespace
43 * we have SLV - server lock volume which is calculated on current number of
44 * granted locks, grant speed for past period, etc - that is, locking load.
45 * This SLV number may be thought as a flow definition for simplicity. It is
46 * sent to clients with each occasion to let them know what is current load
47 * situation on the server. By default, at the beginning, SLV on server is
48 * set max value which is calculated as the following: allow to one client
49 * have all locks of limit ->pl_limit for 10h.
51 * Next, on clients, number of cached locks is not limited artificially in any
52 * way as it was before. Instead, client calculates CLV, that is, client lock
53 * volume for each lock and compares it with last SLV from the server. CLV is
54 * calculated as the number of locks in LRU * lock live time in seconds. If
55 * CLV > SLV - lock is canceled.
57 * Client has LVF, that is, lock volume factor which regulates how much
58 * sensitive client should be about last SLV from server. The higher LVF is the
59 * more locks will be canceled on client. Default value for it is 1. Setting LVF
60 * to 2 means that client will cancel locks 2 times faster.
62 * Locks on a client will be canceled more intensively in these cases:
63 * (1) if SLV is smaller, that is, load is higher on the server;
64 * (2) client has a lot of locks (the more locks are held by client, the bigger
65 * chances that some of them should be canceled);
66 * (3) client has old locks (taken some time ago);
68 * Thus, according to flow paradigm that we use for better understanding SLV,
69 * CLV is the volume of particle in flow described by SLV. According to this,
70 * if flow is getting thinner, more and more particles become outside of it and
71 * as particles are locks, they should be canceled.
73 * General idea of this belongs to Vitaly Fertman (vitaly@clusterfs.com).
74 * Andreas Dilger (adilger@clusterfs.com) proposed few nice ideas like using
75 * LVF and many cleanups. Flow definition to allow more easy understanding of
76 * the logic belongs to Nikita Danilov (nikita@clusterfs.com) as well as many
77 * cleanups and fixes. And design and implementation are done by Yury Umanets
78 * (umka@clusterfs.com).
80 * Glossary for terms used:
82 * pl_limit - Number of allowed locks in pool. Applies to server and client
85 * pl_granted - Number of granted locks (calculated);
86 * pl_grant_rate - Number of granted locks for last T (calculated);
87 * pl_cancel_rate - Number of canceled locks for last T (calculated);
88 * pl_grant_speed - Grant speed (GR - CR) for last T (calculated);
89 * pl_grant_plan - Planned number of granted locks for next T (calculated);
90 * pl_server_lock_volume - Current server lock volume (calculated);
92 * As it may be seen from list above, we have few possible tunables which may
93 * affect behavior much. They all may be modified via sysfs. However, they also
94 * give a possibility for constructing few pre-defined behavior policies. If
95 * none of predefines is suitable for a working pattern being used, new one may
96 * be "constructed" via sysfs tunables.
99 #define DEBUG_SUBSYSTEM S_LDLM
101 #include "../include/lustre_dlm.h"
102 #include "../include/cl_object.h"
103 #include "../include/obd_class.h"
104 #include "../include/obd_support.h"
105 #include "ldlm_internal.h"
109 * 50 ldlm locks for 1MB of RAM.
111 #define LDLM_POOL_HOST_L ((NUM_CACHEPAGES >> (20 - PAGE_CACHE_SHIFT)) * 50)
114 * Maximal possible grant step plan in %.
116 #define LDLM_POOL_MAX_GSP (30)
119 * Minimal possible grant step plan in %.
121 #define LDLM_POOL_MIN_GSP (1)
124 * This controls the speed of reaching LDLM_POOL_MAX_GSP
125 * with increasing thread period.
127 #define LDLM_POOL_GSP_STEP_SHIFT (2)
130 * LDLM_POOL_GSP% of all locks is default GP.
132 #define LDLM_POOL_GP(L) (((L) * LDLM_POOL_MAX_GSP) / 100)
135 * Max age for locks on clients.
137 #define LDLM_POOL_MAX_AGE (36000)
140 * The granularity of SLV calculation.
142 #define LDLM_POOL_SLV_SHIFT (10)
144 static inline __u64 dru(__u64 val, __u32 shift, int round_up)
146 return (val + (round_up ? (1 << shift) - 1 : 0)) >> shift;
149 static inline __u64 ldlm_pool_slv_max(__u32 L)
152 * Allow to have all locks for 1 client for 10 hrs.
153 * Formula is the following: limit * 10h / 1 client.
155 __u64 lim = (__u64)L * LDLM_POOL_MAX_AGE / 1;
159 static inline __u64 ldlm_pool_slv_min(__u32 L)
165 LDLM_POOL_FIRST_STAT = 0,
166 LDLM_POOL_GRANTED_STAT = LDLM_POOL_FIRST_STAT,
167 LDLM_POOL_GRANT_STAT,
168 LDLM_POOL_CANCEL_STAT,
169 LDLM_POOL_GRANT_RATE_STAT,
170 LDLM_POOL_CANCEL_RATE_STAT,
171 LDLM_POOL_GRANT_PLAN_STAT,
173 LDLM_POOL_SHRINK_REQTD_STAT,
174 LDLM_POOL_SHRINK_FREED_STAT,
175 LDLM_POOL_RECALC_STAT,
176 LDLM_POOL_TIMING_STAT,
180 static inline struct ldlm_namespace *ldlm_pl2ns(struct ldlm_pool *pl)
182 return container_of(pl, struct ldlm_namespace, ns_pool);
186 * Calculates suggested grant_step in % of available locks for passed
187 * \a period. This is later used in grant_plan calculations.
189 static inline int ldlm_pool_t2gsp(unsigned int t)
192 * This yields 1% grant step for anything below LDLM_POOL_GSP_STEP
193 * and up to 30% for anything higher than LDLM_POOL_GSP_STEP.
195 * How this will affect execution is the following:
197 * - for thread period 1s we will have grant_step 1% which good from
198 * pov of taking some load off from server and push it out to clients.
199 * This is like that because 1% for grant_step means that server will
200 * not allow clients to get lots of locks in short period of time and
201 * keep all old locks in their caches. Clients will always have to
202 * get some locks back if they want to take some new;
204 * - for thread period 10s (which is default) we will have 23% which
205 * means that clients will have enough of room to take some new locks
206 * without getting some back. All locks from this 23% which were not
207 * taken by clients in current period will contribute in SLV growing.
208 * SLV growing means more locks cached on clients until limit or grant
211 return LDLM_POOL_MAX_GSP -
212 ((LDLM_POOL_MAX_GSP - LDLM_POOL_MIN_GSP) >>
213 (t >> LDLM_POOL_GSP_STEP_SHIFT));
217 * Recalculates next grant limit on passed \a pl.
219 * \pre ->pl_lock is locked.
221 static void ldlm_pool_recalc_grant_plan(struct ldlm_pool *pl)
223 int granted, grant_step, limit;
225 limit = ldlm_pool_get_limit(pl);
226 granted = atomic_read(&pl->pl_granted);
228 grant_step = ldlm_pool_t2gsp(pl->pl_recalc_period);
229 grant_step = ((limit - granted) * grant_step) / 100;
230 pl->pl_grant_plan = granted + grant_step;
231 limit = (limit * 5) >> 2;
232 if (pl->pl_grant_plan > limit)
233 pl->pl_grant_plan = limit;
237 * Recalculates next SLV on passed \a pl.
239 * \pre ->pl_lock is locked.
241 static void ldlm_pool_recalc_slv(struct ldlm_pool *pl)
251 slv = pl->pl_server_lock_volume;
252 grant_plan = pl->pl_grant_plan;
253 limit = ldlm_pool_get_limit(pl);
254 granted = atomic_read(&pl->pl_granted);
255 round_up = granted < limit;
257 grant_usage = max_t(int, limit - (granted - grant_plan), 1);
260 * Find out SLV change factor which is the ratio of grant usage
261 * from limit. SLV changes as fast as the ratio of grant plan
262 * consumption. The more locks from grant plan are not consumed
263 * by clients in last interval (idle time), the faster grows
264 * SLV. And the opposite, the more grant plan is over-consumed
265 * (load time) the faster drops SLV.
267 slv_factor = grant_usage << LDLM_POOL_SLV_SHIFT;
268 do_div(slv_factor, limit);
269 slv = slv * slv_factor;
270 slv = dru(slv, LDLM_POOL_SLV_SHIFT, round_up);
272 if (slv > ldlm_pool_slv_max(limit))
273 slv = ldlm_pool_slv_max(limit);
274 else if (slv < ldlm_pool_slv_min(limit))
275 slv = ldlm_pool_slv_min(limit);
277 pl->pl_server_lock_volume = slv;
281 * Recalculates next stats on passed \a pl.
283 * \pre ->pl_lock is locked.
285 static void ldlm_pool_recalc_stats(struct ldlm_pool *pl)
287 int grant_plan = pl->pl_grant_plan;
288 __u64 slv = pl->pl_server_lock_volume;
289 int granted = atomic_read(&pl->pl_granted);
290 int grant_rate = atomic_read(&pl->pl_grant_rate);
291 int cancel_rate = atomic_read(&pl->pl_cancel_rate);
293 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_SLV_STAT,
295 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_GRANTED_STAT,
297 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_GRANT_RATE_STAT,
299 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_GRANT_PLAN_STAT,
301 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_CANCEL_RATE_STAT,
306 * Sets current SLV into obd accessible via ldlm_pl2ns(pl)->ns_obd.
308 static void ldlm_srv_pool_push_slv(struct ldlm_pool *pl)
310 struct obd_device *obd;
313 * Set new SLV in obd field for using it later without accessing the
314 * pool. This is required to avoid race between sending reply to client
315 * with new SLV and cleanup server stack in which we can't guarantee
316 * that namespace is still alive. We know only that obd is alive as
317 * long as valid export is alive.
319 obd = ldlm_pl2ns(pl)->ns_obd;
320 LASSERT(obd != NULL);
321 write_lock(&obd->obd_pool_lock);
322 obd->obd_pool_slv = pl->pl_server_lock_volume;
323 write_unlock(&obd->obd_pool_lock);
327 * Recalculates all pool fields on passed \a pl.
329 * \pre ->pl_lock is not locked.
331 static int ldlm_srv_pool_recalc(struct ldlm_pool *pl)
333 time_t recalc_interval_sec;
335 recalc_interval_sec = get_seconds() - pl->pl_recalc_time;
336 if (recalc_interval_sec < pl->pl_recalc_period)
339 spin_lock(&pl->pl_lock);
340 recalc_interval_sec = get_seconds() - pl->pl_recalc_time;
341 if (recalc_interval_sec < pl->pl_recalc_period) {
342 spin_unlock(&pl->pl_lock);
346 * Recalc SLV after last period. This should be done
347 * _before_ recalculating new grant plan.
349 ldlm_pool_recalc_slv(pl);
352 * Make sure that pool informed obd of last SLV changes.
354 ldlm_srv_pool_push_slv(pl);
357 * Update grant_plan for new period.
359 ldlm_pool_recalc_grant_plan(pl);
361 pl->pl_recalc_time = get_seconds();
362 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT,
363 recalc_interval_sec);
364 spin_unlock(&pl->pl_lock);
369 * This function is used on server side as main entry point for memory
370 * pressure handling. It decreases SLV on \a pl according to passed
371 * \a nr and \a gfp_mask.
373 * Our goal here is to decrease SLV such a way that clients hold \a nr
374 * locks smaller in next 10h.
376 static int ldlm_srv_pool_shrink(struct ldlm_pool *pl,
377 int nr, gfp_t gfp_mask)
382 * VM is asking how many entries may be potentially freed.
385 return atomic_read(&pl->pl_granted);
388 * Client already canceled locks but server is already in shrinker
389 * and can't cancel anything. Let's catch this race.
391 if (atomic_read(&pl->pl_granted) == 0)
394 spin_lock(&pl->pl_lock);
397 * We want shrinker to possibly cause cancellation of @nr locks from
398 * clients or grant approximately @nr locks smaller next intervals.
400 * This is why we decreased SLV by @nr. This effect will only be as
401 * long as one re-calc interval (1s these days) and this should be
402 * enough to pass this decreased SLV to all clients. On next recalc
403 * interval pool will either increase SLV if locks load is not high
404 * or will keep on same level or even decrease again, thus, shrinker
405 * decreased SLV will affect next recalc intervals and this way will
406 * make locking load lower.
408 if (nr < pl->pl_server_lock_volume) {
409 pl->pl_server_lock_volume = pl->pl_server_lock_volume - nr;
411 limit = ldlm_pool_get_limit(pl);
412 pl->pl_server_lock_volume = ldlm_pool_slv_min(limit);
416 * Make sure that pool informed obd of last SLV changes.
418 ldlm_srv_pool_push_slv(pl);
419 spin_unlock(&pl->pl_lock);
422 * We did not really free any memory here so far, it only will be
423 * freed later may be, so that we return 0 to not confuse VM.
429 * Setup server side pool \a pl with passed \a limit.
431 static int ldlm_srv_pool_setup(struct ldlm_pool *pl, int limit)
433 struct obd_device *obd;
435 obd = ldlm_pl2ns(pl)->ns_obd;
436 LASSERT(obd != NULL && obd != LP_POISON);
437 LASSERT(obd->obd_type != LP_POISON);
438 write_lock(&obd->obd_pool_lock);
439 obd->obd_pool_limit = limit;
440 write_unlock(&obd->obd_pool_lock);
442 ldlm_pool_set_limit(pl, limit);
447 * Sets SLV and Limit from ldlm_pl2ns(pl)->ns_obd tp passed \a pl.
449 static void ldlm_cli_pool_pop_slv(struct ldlm_pool *pl)
451 struct obd_device *obd;
454 * Get new SLV and Limit from obd which is updated with coming
457 obd = ldlm_pl2ns(pl)->ns_obd;
458 LASSERT(obd != NULL);
459 read_lock(&obd->obd_pool_lock);
460 pl->pl_server_lock_volume = obd->obd_pool_slv;
461 ldlm_pool_set_limit(pl, obd->obd_pool_limit);
462 read_unlock(&obd->obd_pool_lock);
466 * Recalculates client size pool \a pl according to current SLV and Limit.
468 static int ldlm_cli_pool_recalc(struct ldlm_pool *pl)
470 time_t recalc_interval_sec;
473 recalc_interval_sec = get_seconds() - pl->pl_recalc_time;
474 if (recalc_interval_sec < pl->pl_recalc_period)
477 spin_lock(&pl->pl_lock);
479 * Check if we need to recalc lists now.
481 recalc_interval_sec = get_seconds() - pl->pl_recalc_time;
482 if (recalc_interval_sec < pl->pl_recalc_period) {
483 spin_unlock(&pl->pl_lock);
488 * Make sure that pool knows last SLV and Limit from obd.
490 ldlm_cli_pool_pop_slv(pl);
492 spin_unlock(&pl->pl_lock);
495 * Do not cancel locks in case lru resize is disabled for this ns.
497 if (!ns_connect_lru_resize(ldlm_pl2ns(pl))) {
503 * In the time of canceling locks on client we do not need to maintain
504 * sharp timing, we only want to cancel locks asap according to new SLV.
505 * It may be called when SLV has changed much, this is why we do not
506 * take into account pl->pl_recalc_time here.
508 ret = ldlm_cancel_lru(ldlm_pl2ns(pl), 0, LCF_ASYNC, LDLM_CANCEL_LRUR);
511 spin_lock(&pl->pl_lock);
513 * Time of LRU resizing might be longer than period,
514 * so update after LRU resizing rather than before it.
516 pl->pl_recalc_time = get_seconds();
517 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT,
518 recalc_interval_sec);
519 spin_unlock(&pl->pl_lock);
524 * This function is main entry point for memory pressure handling on client
525 * side. Main goal of this function is to cancel some number of locks on
526 * passed \a pl according to \a nr and \a gfp_mask.
528 static int ldlm_cli_pool_shrink(struct ldlm_pool *pl,
529 int nr, gfp_t gfp_mask)
531 struct ldlm_namespace *ns;
537 * Do not cancel locks in case lru resize is disabled for this ns.
539 if (!ns_connect_lru_resize(ns))
543 * Make sure that pool knows last SLV and Limit from obd.
545 ldlm_cli_pool_pop_slv(pl);
547 spin_lock(&ns->ns_lock);
548 unused = ns->ns_nr_unused;
549 spin_unlock(&ns->ns_lock);
552 return (unused / 100) * sysctl_vfs_cache_pressure;
554 return ldlm_cancel_lru(ns, nr, LCF_ASYNC, LDLM_CANCEL_SHRINK);
557 static const struct ldlm_pool_ops ldlm_srv_pool_ops = {
558 .po_recalc = ldlm_srv_pool_recalc,
559 .po_shrink = ldlm_srv_pool_shrink,
560 .po_setup = ldlm_srv_pool_setup
563 static const struct ldlm_pool_ops ldlm_cli_pool_ops = {
564 .po_recalc = ldlm_cli_pool_recalc,
565 .po_shrink = ldlm_cli_pool_shrink
569 * Pool recalc wrapper. Will call either client or server pool recalc callback
570 * depending what pool \a pl is used.
572 int ldlm_pool_recalc(struct ldlm_pool *pl)
574 time_t recalc_interval_sec;
577 recalc_interval_sec = get_seconds() - pl->pl_recalc_time;
578 if (recalc_interval_sec <= 0)
581 spin_lock(&pl->pl_lock);
582 if (recalc_interval_sec > 0) {
584 * Update pool statistics every 1s.
586 ldlm_pool_recalc_stats(pl);
589 * Zero out all rates and speed for the last period.
591 atomic_set(&pl->pl_grant_rate, 0);
592 atomic_set(&pl->pl_cancel_rate, 0);
594 spin_unlock(&pl->pl_lock);
597 if (pl->pl_ops->po_recalc != NULL) {
598 count = pl->pl_ops->po_recalc(pl);
599 lprocfs_counter_add(pl->pl_stats, LDLM_POOL_RECALC_STAT,
602 recalc_interval_sec = pl->pl_recalc_time - get_seconds() +
603 pl->pl_recalc_period;
604 if (recalc_interval_sec <= 0) {
605 /* Prevent too frequent recalculation. */
606 CDEBUG(D_DLMTRACE, "Negative interval(%ld), "
607 "too short period(%ld)",
609 pl->pl_recalc_period);
610 recalc_interval_sec = 1;
613 return recalc_interval_sec;
617 * Pool shrink wrapper. Will call either client or server pool recalc callback
618 * depending what pool pl is used. When nr == 0, just return the number of
619 * freeable locks. Otherwise, return the number of canceled locks.
621 int ldlm_pool_shrink(struct ldlm_pool *pl, int nr,
626 if (pl->pl_ops->po_shrink != NULL) {
627 cancel = pl->pl_ops->po_shrink(pl, nr, gfp_mask);
629 lprocfs_counter_add(pl->pl_stats,
630 LDLM_POOL_SHRINK_REQTD_STAT,
632 lprocfs_counter_add(pl->pl_stats,
633 LDLM_POOL_SHRINK_FREED_STAT,
635 CDEBUG(D_DLMTRACE, "%s: request to shrink %d locks, shrunk %d\n",
636 pl->pl_name, nr, cancel);
641 EXPORT_SYMBOL(ldlm_pool_shrink);
644 * Pool setup wrapper. Will call either client or server pool recalc callback
645 * depending what pool \a pl is used.
647 * Sets passed \a limit into pool \a pl.
649 int ldlm_pool_setup(struct ldlm_pool *pl, int limit)
651 if (pl->pl_ops->po_setup != NULL)
652 return pl->pl_ops->po_setup(pl, limit);
655 EXPORT_SYMBOL(ldlm_pool_setup);
657 static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused)
659 int granted, grant_rate, cancel_rate, grant_step;
660 int grant_speed, grant_plan, lvf;
661 struct ldlm_pool *pl = m->private;
665 spin_lock(&pl->pl_lock);
666 slv = pl->pl_server_lock_volume;
667 clv = pl->pl_client_lock_volume;
668 limit = ldlm_pool_get_limit(pl);
669 grant_plan = pl->pl_grant_plan;
670 granted = atomic_read(&pl->pl_granted);
671 grant_rate = atomic_read(&pl->pl_grant_rate);
672 cancel_rate = atomic_read(&pl->pl_cancel_rate);
673 grant_speed = grant_rate - cancel_rate;
674 lvf = atomic_read(&pl->pl_lock_volume_factor);
675 grant_step = ldlm_pool_t2gsp(pl->pl_recalc_period);
676 spin_unlock(&pl->pl_lock);
678 seq_printf(m, "LDLM pool state (%s):\n"
682 pl->pl_name, slv, clv, lvf);
684 if (ns_is_server(ldlm_pl2ns(pl))) {
685 seq_printf(m, " GSP: %d%%\n"
687 grant_step, grant_plan);
689 seq_printf(m, " GR: %d\n CR: %d\n GS: %d\n"
691 grant_rate, cancel_rate, grant_speed,
696 LPROC_SEQ_FOPS_RO(lprocfs_pool_state);
698 static ssize_t grant_speed_show(struct kobject *kobj, struct attribute *attr,
701 struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool,
706 spin_lock(&pl->pl_lock);
707 /* serialize with ldlm_pool_recalc */
708 grant_speed = atomic_read(&pl->pl_grant_rate) -
709 atomic_read(&pl->pl_cancel_rate);
710 spin_unlock(&pl->pl_lock);
711 return sprintf(buf, "%d\n", grant_speed);
713 LUSTRE_RO_ATTR(grant_speed);
715 LDLM_POOL_SYSFS_READER_SHOW(grant_plan, int);
716 LUSTRE_RO_ATTR(grant_plan);
718 LDLM_POOL_SYSFS_READER_SHOW(recalc_period, int);
719 LDLM_POOL_SYSFS_WRITER_STORE(recalc_period, int);
720 LUSTRE_RW_ATTR(recalc_period);
722 LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(server_lock_volume, u64);
723 LUSTRE_RO_ATTR(server_lock_volume);
725 LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(limit, atomic);
726 LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(limit, atomic);
727 LUSTRE_RW_ATTR(limit);
729 LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(granted, atomic);
730 LUSTRE_RO_ATTR(granted);
732 LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(cancel_rate, atomic);
733 LUSTRE_RO_ATTR(cancel_rate);
735 LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(grant_rate, atomic);
736 LUSTRE_RO_ATTR(grant_rate);
738 LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(lock_volume_factor, atomic);
739 LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(lock_volume_factor, atomic);
740 LUSTRE_RW_ATTR(lock_volume_factor);
742 #define LDLM_POOL_ADD_VAR(name, var, ops) \
744 snprintf(var_name, MAX_STRING_SIZE, #name); \
745 pool_vars[0].data = var; \
746 pool_vars[0].fops = ops; \
747 ldebugfs_add_vars(pl->pl_debugfs_entry, pool_vars, NULL);\
750 /* These are for pools in /sys/fs/lustre/ldlm/namespaces/.../pool */
751 static struct attribute *ldlm_pl_attrs[] = {
752 &lustre_attr_grant_speed.attr,
753 &lustre_attr_grant_plan.attr,
754 &lustre_attr_recalc_period.attr,
755 &lustre_attr_server_lock_volume.attr,
756 &lustre_attr_limit.attr,
757 &lustre_attr_granted.attr,
758 &lustre_attr_cancel_rate.attr,
759 &lustre_attr_grant_rate.attr,
760 &lustre_attr_lock_volume_factor.attr,
764 static void ldlm_pl_release(struct kobject *kobj)
766 struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool,
768 complete(&pl->pl_kobj_unregister);
771 static struct kobj_type ldlm_pl_ktype = {
772 .default_attrs = ldlm_pl_attrs,
773 .sysfs_ops = &lustre_sysfs_ops,
774 .release = ldlm_pl_release,
777 static int ldlm_pool_sysfs_init(struct ldlm_pool *pl)
779 struct ldlm_namespace *ns = ldlm_pl2ns(pl);
782 init_completion(&pl->pl_kobj_unregister);
783 err = kobject_init_and_add(&pl->pl_kobj, &ldlm_pl_ktype, &ns->ns_kobj,
789 static int ldlm_pool_debugfs_init(struct ldlm_pool *pl)
791 struct ldlm_namespace *ns = ldlm_pl2ns(pl);
792 struct dentry *debugfs_ns_parent;
793 struct lprocfs_vars pool_vars[2];
794 char *var_name = NULL;
797 var_name = kzalloc(MAX_STRING_SIZE + 1, GFP_NOFS);
801 debugfs_ns_parent = ns->ns_debugfs_entry;
802 if (IS_ERR_OR_NULL(debugfs_ns_parent)) {
803 CERROR("%s: debugfs entry is not initialized\n",
808 pl->pl_debugfs_entry = ldebugfs_register("pool", debugfs_ns_parent,
810 if (IS_ERR(pl->pl_debugfs_entry)) {
811 CERROR("LdebugFS failed in ldlm-pool-init\n");
812 rc = PTR_ERR(pl->pl_debugfs_entry);
813 pl->pl_debugfs_entry = NULL;
817 var_name[MAX_STRING_SIZE] = '\0';
818 memset(pool_vars, 0, sizeof(pool_vars));
819 pool_vars[0].name = var_name;
821 LDLM_POOL_ADD_VAR(state, pl, &lprocfs_pool_state_fops);
823 pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT -
824 LDLM_POOL_FIRST_STAT, 0);
830 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANTED_STAT,
831 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
833 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANT_STAT,
834 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
836 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_CANCEL_STAT,
837 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
839 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANT_RATE_STAT,
840 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
841 "grant_rate", "locks/s");
842 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_CANCEL_RATE_STAT,
843 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
844 "cancel_rate", "locks/s");
845 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANT_PLAN_STAT,
846 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
847 "grant_plan", "locks/s");
848 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_SLV_STAT,
849 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
851 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_SHRINK_REQTD_STAT,
852 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
853 "shrink_request", "locks");
854 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_SHRINK_FREED_STAT,
855 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
856 "shrink_freed", "locks");
857 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_RECALC_STAT,
858 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
859 "recalc_freed", "locks");
860 lprocfs_counter_init(pl->pl_stats, LDLM_POOL_TIMING_STAT,
861 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
862 "recalc_timing", "sec");
863 rc = ldebugfs_register_stats(pl->pl_debugfs_entry, "stats",
871 static void ldlm_pool_sysfs_fini(struct ldlm_pool *pl)
873 kobject_put(&pl->pl_kobj);
874 wait_for_completion(&pl->pl_kobj_unregister);
877 static void ldlm_pool_debugfs_fini(struct ldlm_pool *pl)
879 if (pl->pl_stats != NULL) {
880 lprocfs_free_stats(&pl->pl_stats);
883 if (pl->pl_debugfs_entry != NULL) {
884 ldebugfs_remove(&pl->pl_debugfs_entry);
885 pl->pl_debugfs_entry = NULL;
889 int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
890 int idx, ldlm_side_t client)
894 spin_lock_init(&pl->pl_lock);
895 atomic_set(&pl->pl_granted, 0);
896 pl->pl_recalc_time = get_seconds();
897 atomic_set(&pl->pl_lock_volume_factor, 1);
899 atomic_set(&pl->pl_grant_rate, 0);
900 atomic_set(&pl->pl_cancel_rate, 0);
901 pl->pl_grant_plan = LDLM_POOL_GP(LDLM_POOL_HOST_L);
903 snprintf(pl->pl_name, sizeof(pl->pl_name), "ldlm-pool-%s-%d",
904 ldlm_ns_name(ns), idx);
906 if (client == LDLM_NAMESPACE_SERVER) {
907 pl->pl_ops = &ldlm_srv_pool_ops;
908 ldlm_pool_set_limit(pl, LDLM_POOL_HOST_L);
909 pl->pl_recalc_period = LDLM_POOL_SRV_DEF_RECALC_PERIOD;
910 pl->pl_server_lock_volume = ldlm_pool_slv_max(LDLM_POOL_HOST_L);
912 ldlm_pool_set_limit(pl, 1);
913 pl->pl_server_lock_volume = 0;
914 pl->pl_ops = &ldlm_cli_pool_ops;
915 pl->pl_recalc_period = LDLM_POOL_CLI_DEF_RECALC_PERIOD;
917 pl->pl_client_lock_volume = 0;
918 rc = ldlm_pool_debugfs_init(pl);
922 rc = ldlm_pool_sysfs_init(pl);
926 CDEBUG(D_DLMTRACE, "Lock pool %s is initialized\n", pl->pl_name);
930 EXPORT_SYMBOL(ldlm_pool_init);
932 void ldlm_pool_fini(struct ldlm_pool *pl)
934 ldlm_pool_sysfs_fini(pl);
935 ldlm_pool_debugfs_fini(pl);
938 * Pool should not be used after this point. We can't free it here as
939 * it lives in struct ldlm_namespace, but still interested in catching
940 * any abnormal using cases.
942 POISON(pl, 0x5a, sizeof(*pl));
944 EXPORT_SYMBOL(ldlm_pool_fini);
947 * Add new taken ldlm lock \a lock into pool \a pl accounting.
949 void ldlm_pool_add(struct ldlm_pool *pl, struct ldlm_lock *lock)
952 * FLOCK locks are special in a sense that they are almost never
953 * cancelled, instead special kind of lock is used to drop them.
954 * also there is no LRU for flock locks, so no point in tracking
957 if (lock->l_resource->lr_type == LDLM_FLOCK)
960 atomic_inc(&pl->pl_granted);
961 atomic_inc(&pl->pl_grant_rate);
962 lprocfs_counter_incr(pl->pl_stats, LDLM_POOL_GRANT_STAT);
964 * Do not do pool recalc for client side as all locks which
965 * potentially may be canceled has already been packed into
966 * enqueue/cancel rpc. Also we do not want to run out of stack
967 * with too long call paths.
969 if (ns_is_server(ldlm_pl2ns(pl)))
970 ldlm_pool_recalc(pl);
972 EXPORT_SYMBOL(ldlm_pool_add);
975 * Remove ldlm lock \a lock from pool \a pl accounting.
977 void ldlm_pool_del(struct ldlm_pool *pl, struct ldlm_lock *lock)
980 * Filter out FLOCK locks. Read above comment in ldlm_pool_add().
982 if (lock->l_resource->lr_type == LDLM_FLOCK)
985 LASSERT(atomic_read(&pl->pl_granted) > 0);
986 atomic_dec(&pl->pl_granted);
987 atomic_inc(&pl->pl_cancel_rate);
989 lprocfs_counter_incr(pl->pl_stats, LDLM_POOL_CANCEL_STAT);
991 if (ns_is_server(ldlm_pl2ns(pl)))
992 ldlm_pool_recalc(pl);
994 EXPORT_SYMBOL(ldlm_pool_del);
997 * Returns current \a pl SLV.
999 * \pre ->pl_lock is not locked.
1001 __u64 ldlm_pool_get_slv(struct ldlm_pool *pl)
1005 spin_lock(&pl->pl_lock);
1006 slv = pl->pl_server_lock_volume;
1007 spin_unlock(&pl->pl_lock);
1010 EXPORT_SYMBOL(ldlm_pool_get_slv);
1013 * Sets passed \a slv to \a pl.
1015 * \pre ->pl_lock is not locked.
1017 void ldlm_pool_set_slv(struct ldlm_pool *pl, __u64 slv)
1019 spin_lock(&pl->pl_lock);
1020 pl->pl_server_lock_volume = slv;
1021 spin_unlock(&pl->pl_lock);
1023 EXPORT_SYMBOL(ldlm_pool_set_slv);
1026 * Returns current \a pl CLV.
1028 * \pre ->pl_lock is not locked.
1030 __u64 ldlm_pool_get_clv(struct ldlm_pool *pl)
1034 spin_lock(&pl->pl_lock);
1035 slv = pl->pl_client_lock_volume;
1036 spin_unlock(&pl->pl_lock);
1039 EXPORT_SYMBOL(ldlm_pool_get_clv);
1042 * Sets passed \a clv to \a pl.
1044 * \pre ->pl_lock is not locked.
1046 void ldlm_pool_set_clv(struct ldlm_pool *pl, __u64 clv)
1048 spin_lock(&pl->pl_lock);
1049 pl->pl_client_lock_volume = clv;
1050 spin_unlock(&pl->pl_lock);
1052 EXPORT_SYMBOL(ldlm_pool_set_clv);
1055 * Returns current \a pl limit.
1057 __u32 ldlm_pool_get_limit(struct ldlm_pool *pl)
1059 return atomic_read(&pl->pl_limit);
1061 EXPORT_SYMBOL(ldlm_pool_get_limit);
1064 * Sets passed \a limit to \a pl.
1066 void ldlm_pool_set_limit(struct ldlm_pool *pl, __u32 limit)
1068 atomic_set(&pl->pl_limit, limit);
1070 EXPORT_SYMBOL(ldlm_pool_set_limit);
1073 * Returns current LVF from \a pl.
1075 __u32 ldlm_pool_get_lvf(struct ldlm_pool *pl)
1077 return atomic_read(&pl->pl_lock_volume_factor);
1079 EXPORT_SYMBOL(ldlm_pool_get_lvf);
1081 static int ldlm_pool_granted(struct ldlm_pool *pl)
1083 return atomic_read(&pl->pl_granted);
1086 static struct ptlrpc_thread *ldlm_pools_thread;
1087 static struct completion ldlm_pools_comp;
1090 * count locks from all namespaces (if possible). Returns number of
1093 static unsigned long ldlm_pools_count(ldlm_side_t client, gfp_t gfp_mask)
1095 int total = 0, nr_ns;
1096 struct ldlm_namespace *ns;
1097 struct ldlm_namespace *ns_old = NULL; /* loop detection */
1100 if (client == LDLM_NAMESPACE_CLIENT && !(gfp_mask & __GFP_FS))
1103 CDEBUG(D_DLMTRACE, "Request to count %s locks from all pools\n",
1104 client == LDLM_NAMESPACE_CLIENT ? "client" : "server");
1106 cookie = cl_env_reenter();
1109 * Find out how many resources we may release.
1111 for (nr_ns = ldlm_namespace_nr_read(client);
1112 nr_ns > 0; nr_ns--) {
1113 mutex_lock(ldlm_namespace_lock(client));
1114 if (list_empty(ldlm_namespace_list(client))) {
1115 mutex_unlock(ldlm_namespace_lock(client));
1116 cl_env_reexit(cookie);
1119 ns = ldlm_namespace_first_locked(client);
1122 mutex_unlock(ldlm_namespace_lock(client));
1126 if (ldlm_ns_empty(ns)) {
1127 ldlm_namespace_move_to_inactive_locked(ns, client);
1128 mutex_unlock(ldlm_namespace_lock(client));
1135 ldlm_namespace_get(ns);
1136 ldlm_namespace_move_to_active_locked(ns, client);
1137 mutex_unlock(ldlm_namespace_lock(client));
1138 total += ldlm_pool_shrink(&ns->ns_pool, 0, gfp_mask);
1139 ldlm_namespace_put(ns);
1142 cl_env_reexit(cookie);
1146 static unsigned long ldlm_pools_scan(ldlm_side_t client, int nr, gfp_t gfp_mask)
1148 unsigned long freed = 0;
1150 struct ldlm_namespace *ns;
1153 if (client == LDLM_NAMESPACE_CLIENT && !(gfp_mask & __GFP_FS))
1156 cookie = cl_env_reenter();
1159 * Shrink at least ldlm_namespace_nr_read(client) namespaces.
1161 for (tmp = nr_ns = ldlm_namespace_nr_read(client);
1163 int cancel, nr_locks;
1166 * Do not call shrink under ldlm_namespace_lock(client)
1168 mutex_lock(ldlm_namespace_lock(client));
1169 if (list_empty(ldlm_namespace_list(client))) {
1170 mutex_unlock(ldlm_namespace_lock(client));
1173 ns = ldlm_namespace_first_locked(client);
1174 ldlm_namespace_get(ns);
1175 ldlm_namespace_move_to_active_locked(ns, client);
1176 mutex_unlock(ldlm_namespace_lock(client));
1178 nr_locks = ldlm_pool_granted(&ns->ns_pool);
1180 * We use to shrink propotionally but with new shrinker API,
1181 * we lost the total number of freeable locks.
1183 cancel = 1 + min_t(int, nr_locks, nr / nr_ns);
1184 freed += ldlm_pool_shrink(&ns->ns_pool, cancel, gfp_mask);
1185 ldlm_namespace_put(ns);
1187 cl_env_reexit(cookie);
1189 * we only decrease the SLV in server pools shrinker, return
1190 * SHRINK_STOP to kernel to avoid needless loop. LU-1128
1192 return (client == LDLM_NAMESPACE_SERVER) ? SHRINK_STOP : freed;
1195 static unsigned long ldlm_pools_srv_count(struct shrinker *s,
1196 struct shrink_control *sc)
1198 return ldlm_pools_count(LDLM_NAMESPACE_SERVER, sc->gfp_mask);
1201 static unsigned long ldlm_pools_srv_scan(struct shrinker *s,
1202 struct shrink_control *sc)
1204 return ldlm_pools_scan(LDLM_NAMESPACE_SERVER, sc->nr_to_scan,
1208 static unsigned long ldlm_pools_cli_count(struct shrinker *s,
1209 struct shrink_control *sc)
1211 return ldlm_pools_count(LDLM_NAMESPACE_CLIENT, sc->gfp_mask);
1214 static unsigned long ldlm_pools_cli_scan(struct shrinker *s,
1215 struct shrink_control *sc)
1217 return ldlm_pools_scan(LDLM_NAMESPACE_CLIENT, sc->nr_to_scan,
1221 int ldlm_pools_recalc(ldlm_side_t client)
1223 __u32 nr_l = 0, nr_p = 0, l;
1224 struct ldlm_namespace *ns;
1225 struct ldlm_namespace *ns_old = NULL;
1227 int time = 50; /* seconds of sleep if no active namespaces */
1230 * No need to setup pool limit for client pools.
1232 if (client == LDLM_NAMESPACE_SERVER) {
1234 * Check all modest namespaces first.
1236 mutex_lock(ldlm_namespace_lock(client));
1237 list_for_each_entry(ns, ldlm_namespace_list(client),
1239 if (ns->ns_appetite != LDLM_NAMESPACE_MODEST)
1242 l = ldlm_pool_granted(&ns->ns_pool);
1247 * Set the modest pools limit equal to their avg granted
1250 l += dru(l, LDLM_POOLS_MODEST_MARGIN_SHIFT, 0);
1251 ldlm_pool_setup(&ns->ns_pool, l);
1257 * Make sure that modest namespaces did not eat more that 2/3
1260 if (nr_l >= 2 * (LDLM_POOL_HOST_L / 3)) {
1261 CWARN("\"Modest\" pools eat out 2/3 of server locks limit (%d of %lu). This means that you have too many clients for this amount of server RAM. Upgrade server!\n",
1262 nr_l, LDLM_POOL_HOST_L);
1267 * The rest is given to greedy namespaces.
1269 list_for_each_entry(ns, ldlm_namespace_list(client),
1271 if (!equal && ns->ns_appetite != LDLM_NAMESPACE_GREEDY)
1276 * In the case 2/3 locks are eaten out by
1277 * modest pools, we re-setup equal limit
1280 l = LDLM_POOL_HOST_L /
1281 ldlm_namespace_nr_read(client);
1284 * All the rest of greedy pools will have
1285 * all locks in equal parts.
1287 l = (LDLM_POOL_HOST_L - nr_l) /
1288 (ldlm_namespace_nr_read(client) -
1291 ldlm_pool_setup(&ns->ns_pool, l);
1293 mutex_unlock(ldlm_namespace_lock(client));
1297 * Recalc at least ldlm_namespace_nr_read(client) namespaces.
1299 for (nr = ldlm_namespace_nr_read(client); nr > 0; nr--) {
1302 * Lock the list, get first @ns in the list, getref, move it
1303 * to the tail, unlock and call pool recalc. This way we avoid
1304 * calling recalc under @ns lock what is really good as we get
1305 * rid of potential deadlock on client nodes when canceling
1306 * locks synchronously.
1308 mutex_lock(ldlm_namespace_lock(client));
1309 if (list_empty(ldlm_namespace_list(client))) {
1310 mutex_unlock(ldlm_namespace_lock(client));
1313 ns = ldlm_namespace_first_locked(client);
1315 if (ns_old == ns) { /* Full pass complete */
1316 mutex_unlock(ldlm_namespace_lock(client));
1320 /* We got an empty namespace, need to move it back to inactive
1322 * The race with parallel resource creation is fine:
1323 * - If they do namespace_get before our check, we fail the
1324 * check and they move this item to the end of the list anyway
1325 * - If we do the check and then they do namespace_get, then
1326 * we move the namespace to inactive and they will move
1327 * it back to active (synchronised by the lock, so no clash
1330 if (ldlm_ns_empty(ns)) {
1331 ldlm_namespace_move_to_inactive_locked(ns, client);
1332 mutex_unlock(ldlm_namespace_lock(client));
1339 spin_lock(&ns->ns_lock);
1341 * skip ns which is being freed, and we don't want to increase
1342 * its refcount again, not even temporarily. bz21519 & LU-499.
1344 if (ns->ns_stopping) {
1348 ldlm_namespace_get(ns);
1350 spin_unlock(&ns->ns_lock);
1352 ldlm_namespace_move_to_active_locked(ns, client);
1353 mutex_unlock(ldlm_namespace_lock(client));
1356 * After setup is done - recalc the pool.
1359 int ttime = ldlm_pool_recalc(&ns->ns_pool);
1364 ldlm_namespace_put(ns);
1369 EXPORT_SYMBOL(ldlm_pools_recalc);
1371 static int ldlm_pools_thread_main(void *arg)
1373 struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg;
1376 thread_set_flags(thread, SVC_RUNNING);
1377 wake_up(&thread->t_ctl_waitq);
1379 CDEBUG(D_DLMTRACE, "%s: pool thread starting, process %d\n",
1380 "ldlm_poold", current_pid());
1383 struct l_wait_info lwi;
1386 * Recal all pools on this tick.
1388 s_time = ldlm_pools_recalc(LDLM_NAMESPACE_SERVER);
1389 c_time = ldlm_pools_recalc(LDLM_NAMESPACE_CLIENT);
1392 * Wait until the next check time, or until we're
1395 lwi = LWI_TIMEOUT(cfs_time_seconds(min(s_time, c_time)),
1397 l_wait_event(thread->t_ctl_waitq,
1398 thread_is_stopping(thread) ||
1399 thread_is_event(thread),
1402 if (thread_test_and_clear_flags(thread, SVC_STOPPING))
1405 thread_test_and_clear_flags(thread, SVC_EVENT);
1408 thread_set_flags(thread, SVC_STOPPED);
1409 wake_up(&thread->t_ctl_waitq);
1411 CDEBUG(D_DLMTRACE, "%s: pool thread exiting, process %d\n",
1412 "ldlm_poold", current_pid());
1414 complete_and_exit(&ldlm_pools_comp, 0);
1417 static int ldlm_pools_thread_start(void)
1419 struct l_wait_info lwi = { 0 };
1420 struct task_struct *task;
1422 if (ldlm_pools_thread != NULL)
1425 ldlm_pools_thread = kzalloc(sizeof(*ldlm_pools_thread), GFP_NOFS);
1426 if (ldlm_pools_thread == NULL)
1429 init_completion(&ldlm_pools_comp);
1430 init_waitqueue_head(&ldlm_pools_thread->t_ctl_waitq);
1432 task = kthread_run(ldlm_pools_thread_main, ldlm_pools_thread,
1435 CERROR("Can't start pool thread, error %ld\n", PTR_ERR(task));
1436 kfree(ldlm_pools_thread);
1437 ldlm_pools_thread = NULL;
1438 return PTR_ERR(task);
1440 l_wait_event(ldlm_pools_thread->t_ctl_waitq,
1441 thread_is_running(ldlm_pools_thread), &lwi);
1445 static void ldlm_pools_thread_stop(void)
1447 if (ldlm_pools_thread == NULL)
1450 thread_set_flags(ldlm_pools_thread, SVC_STOPPING);
1451 wake_up(&ldlm_pools_thread->t_ctl_waitq);
1454 * Make sure that pools thread is finished before freeing @thread.
1455 * This fixes possible race and oops due to accessing freed memory
1458 wait_for_completion(&ldlm_pools_comp);
1459 kfree(ldlm_pools_thread);
1460 ldlm_pools_thread = NULL;
1463 static struct shrinker ldlm_pools_srv_shrinker = {
1464 .count_objects = ldlm_pools_srv_count,
1465 .scan_objects = ldlm_pools_srv_scan,
1466 .seeks = DEFAULT_SEEKS,
1469 static struct shrinker ldlm_pools_cli_shrinker = {
1470 .count_objects = ldlm_pools_cli_count,
1471 .scan_objects = ldlm_pools_cli_scan,
1472 .seeks = DEFAULT_SEEKS,
1475 int ldlm_pools_init(void)
1479 rc = ldlm_pools_thread_start();
1481 register_shrinker(&ldlm_pools_srv_shrinker);
1482 register_shrinker(&ldlm_pools_cli_shrinker);
1486 EXPORT_SYMBOL(ldlm_pools_init);
1488 void ldlm_pools_fini(void)
1490 unregister_shrinker(&ldlm_pools_srv_shrinker);
1491 unregister_shrinker(&ldlm_pools_cli_shrinker);
1492 ldlm_pools_thread_stop();
1494 EXPORT_SYMBOL(ldlm_pools_fini);