*/
#include "gnilnd.h"
+#include <linux/swap.h>
void
kgnilnd_setup_smsg_attr(gni_smsg_attr_t *smsg_attr)
* to memory exhaustion during massive reconnects during a network
* outage. Limit the amount of fma blocks to use by always keeping
* a percent of pages free initially set to 25% of total memory. */
- if (global_page_state(NR_FREE_PAGES) < kgnilnd_data.free_pages_limit) {
+ if (nr_free_pages() < kgnilnd_data.free_pages_limit) {
LCONSOLE_INFO("Exceeding free page limit of %ld. "
"Free pages available %ld\n",
kgnilnd_data.free_pages_limit,
- global_page_state(NR_FREE_PAGES));
+ nr_free_pages());
return -ENOMEM;
}
#endif
}
/* allocate just enough space for the bits to track the mailboxes */
- LIBCFS_ALLOC(fma_blk->gnm_bit_array, BITS_TO_LONGS(num_mbox) * sizeof(unsigned long));
+ CFS_ALLOC_PTR_ARRAY(fma_blk->gnm_bit_array, BITS_TO_LONGS(num_mbox));
if (fma_blk->gnm_bit_array == NULL) {
CNETERR("could not allocate mailbox bitmask, %lu bytes for %d mbox\n",
sizeof(unsigned long) * BITS_TO_LONGS(num_mbox), num_mbox);
}
bitmap_zero(fma_blk->gnm_bit_array, num_mbox);
- /* now that the num_mbox is set based on allocation type, get debug info setup */
- LIBCFS_ALLOC(fma_blk->gnm_mbox_info, sizeof(kgn_mbox_info_t) * num_mbox);
+ /* now that the num_mbox is set based on allocation type, get debug
+ * info setup
+ * */
+ CFS_ALLOC_PTR_ARRAY(fma_blk->gnm_mbox_info, num_mbox);
if (fma_blk->gnm_mbox_info == NULL) {
CNETERR("could not allocate mailbox debug, %lu bytes for %d mbox\n",
sizeof(kgn_mbox_info_t) * num_mbox, num_mbox);
return 0;
free_info:
- LIBCFS_FREE(fma_blk->gnm_mbox_info, sizeof(kgn_mbox_info_t)*num_mbox);
+ CFS_FREE_PTR_ARRAY(fma_blk->gnm_mbox_info, num_mbox);
free_bit:
- LIBCFS_FREE(fma_blk->gnm_bit_array, BITS_TO_LONGS(num_mbox) * sizeof (unsigned long));
+ CFS_FREE_PTR_ARRAY(fma_blk->gnm_bit_array, BITS_TO_LONGS(num_mbox));
free_blk:
if (fma_blk->gnm_state == GNILND_FMABLK_VIRT) {
kgnilnd_vfree(fma_blk->gnm_block, fma_blk->gnm_blk_size);
list_del(&fma_blk->gnm_bufflist);
- LIBCFS_FREE(fma_blk->gnm_mbox_info, sizeof(kgn_mbox_info_t)*fma_blk->gnm_num_mboxs);
- LIBCFS_FREE(fma_blk->gnm_bit_array, BITS_TO_LONGS(fma_blk->gnm_num_mboxs) * sizeof (unsigned long));
+ CFS_FREE_PTR_ARRAY(fma_blk->gnm_mbox_info, fma_blk->gnm_num_mboxs);
+ CFS_FREE_PTR_ARRAY(fma_blk->gnm_bit_array,
+ BITS_TO_LONGS(fma_blk->gnm_num_mboxs));
LIBCFS_FREE(fma_blk, sizeof(kgn_fma_memblock_t));
}
fma_blk->gnm_hndl.qword1, fma_blk->gnm_hndl.qword2);
fma_blk->gnm_held_mboxs++;
- fma_blk->gnm_max_timeout = MAX(fma_blk->gnm_max_timeout,
- conn->gnc_timeout);
+ fma_blk->gnm_max_timeout = max_t(long, fma_blk->gnm_max_timeout,
+ conn->gnc_timeout);
} else {
CDEBUG(D_NET, "conn %p smsg %p fmablk %p release SMSG mbox %d "
"hndl %#llx.%#llx\n",
rc = kgnilnd_find_net(connreq->gncr_dstnid, &net);
if (rc == -ESHUTDOWN) {
- CERROR("Looking up network: device is in shutdown");
+ CERROR("Looking up network: device is in shutdown\n");
return rc;
} else if (rc == -ENONET) {
CERROR("Connection data from %s: she sent "
{
kgn_dgram_t *dgram;
- dgram = kmem_cache_alloc(kgnilnd_data.kgn_dgram_cache, GFP_ATOMIC);
+ dgram = kmem_cache_zalloc(kgnilnd_data.kgn_dgram_cache, GFP_ATOMIC);
if (dgram == NULL)
return -ENOMEM;
- /* cache alloc'd memory is not zeroed */
- memset((void *)dgram, 0, sizeof(*dgram)) ;
-
INIT_LIST_HEAD(&dgram->gndg_list);
dgram->gndg_state = GNILND_DGRAM_USED;
dgram->gndg_type = type;
int
kgnilnd_cancel_net_dgrams(kgn_net_t *net)
{
- kgn_dgram_t *dg, *dgN;
- struct list_head zombies;
- int i;
+ kgn_dgram_t *dg, *dgN;
+ LIST_HEAD(zombies);
+ int i;
ENTRY;
/* we want to cancel any outstanding dgrams - we don't want to rely
"in reset %d\n", net->gnn_shutdown,
kgnilnd_data.kgn_in_reset);
- INIT_LIST_HEAD(&zombies);
-
spin_lock(&net->gnn_dev->gnd_dgram_lock);
for (i = 0; i < *kgnilnd_tunables.kgn_peer_hash_size; i++) {
kgnilnd_cancel_wc_dgrams(kgn_device_t *dev)
{
kgn_dgram_t *dg, *dgN;
- struct list_head zombies;
+ LIST_HEAD(zombies);
ENTRY;
/* Time to kill the outstanding WC's
"in reset %d\n", kgnilnd_data.kgn_wc_kill,
kgnilnd_data.kgn_in_reset);
- INIT_LIST_HEAD(&zombies);
spin_lock(&dev->gnd_dgram_lock);
do {
kgnilnd_cancel_dgram_locked(dg);
/* WC could be DONE already, check and if so add to list to be released */
- if (dg->gndg_state == GNILND_DGRAM_DONE) {
- list_del_init(&dg->gndg_list);
- list_add_tail(&dg->gndg_list, &zombies);
- }
+ if (dg->gndg_state == GNILND_DGRAM_DONE)
+ list_move_tail(&dg->gndg_list, &zombies);
}
} while (dg != NULL);
DEFINE_WAIT(mover_done);
snprintf(name, sizeof(name), "kgnilnd_dgn_%02d", dev->gnd_id);
- cfs_block_allsigs();
/* all gnilnd threads need to run fairly urgently */
set_user_nice(current, *kgnilnd_tunables.kgn_nice);
RETURN(did_something);
}
+struct kgnilnd_dgram_timer {
+ struct timer_list timer;
+ kgn_device_t *dev;
+};
+
static void
-kgnilnd_dgram_poke_with_stick(unsigned long arg)
+kgnilnd_dgram_poke_with_stick(cfs_timer_cb_arg_t arg)
{
- int dev_id = arg;
- kgn_device_t *dev = &kgnilnd_data.kgn_devices[dev_id];
+ struct kgnilnd_dgram_timer *t = cfs_from_timer(t, arg, timer);
- wake_up(&dev->gnd_dgram_waitq);
+ wake_up(&t->dev->gnd_dgram_waitq);
}
/* use single thread for dgrams - should be sufficient for performance */
int rc, did_something;
unsigned long next_purge_check = jiffies - 1;
unsigned long timeout;
- struct timer_list timer;
- unsigned long deadline = 0;
+ struct kgnilnd_dgram_timer timer;
+ unsigned long deadline = 0;
DEFINE_WAIT(wait);
snprintf(name, sizeof(name), "kgnilnd_dg_%02d", dev->gnd_id);
- cfs_block_allsigs();
+
/* all gnilnd threads need to run fairly urgently */
set_user_nice(current, *kgnilnd_tunables.kgn_nice);
prepare_to_wait(&dev->gnd_dgram_waitq, &wait, TASK_INTERRUPTIBLE);
- setup_timer(&timer, kgnilnd_dgram_poke_with_stick, dev->gnd_id);
- mod_timer(&timer, (long) jiffies + timeout);
+ cfs_timer_setup(&timer.timer,
+ kgnilnd_dgram_poke_with_stick,
+ dev, 0);
+ timer.dev = dev;
+ mod_timer(&timer.timer, (long) jiffies + timeout);
/* last second chance for others to poke us */
did_something += xchg(&dev->gnd_dgram_ready, GNILND_DGRAM_IDLE);
deadline = jiffies + cfs_time_seconds(*kgnilnd_tunables.kgn_dgram_timeout);
}
- del_singleshot_timer_sync(&timer);
+ del_singleshot_timer_sync(&timer.timer);
finish_wait(&dev->gnd_dgram_waitq, &wait);
}