-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
*
+ * Copyright (c) 2011, 2013, Intel Corporation.
+ *
* Author: Zach Brown <zab@zabbo.net>
* Author: Peter J. Braam <braam@clusterfs.com>
* Author: Phil Schwan <phil@clusterfs.com>
*/
#define DEBUG_PORTAL_ALLOC
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
-
#define DEBUG_SUBSYSTEM S_LND
#if defined(__linux__)
# define SOCKNAL_RISK_KMAP_DEADLOCK 1
#endif
+struct ksock_sched_info;
+
typedef struct /* per scheduler state */
{
- cfs_spinlock_t kss_lock; /* serialise */
- cfs_list_t kss_rx_conns; /* conn waiting to be read */
- cfs_list_t kss_tx_conns; /* conn waiting to be written */
- cfs_list_t kss_zombie_noop_txs; /* zombie noop tx list */
- cfs_waitq_t kss_waitq; /* where scheduler sleeps */
- int kss_nconns; /* # connections assigned to this scheduler */
+ spinlock_t kss_lock; /* serialise */
+ cfs_list_t kss_rx_conns; /* conn waiting to be read */
+ /* conn waiting to be written */
+ cfs_list_t kss_tx_conns;
+ /* zombie noop tx list */
+ cfs_list_t kss_zombie_noop_txs;
+ cfs_waitq_t kss_waitq; /* where scheduler sleeps */
+ /* # connections assigned to this scheduler */
+ int kss_nconns;
+ struct ksock_sched_info *kss_info; /* owner of it */
#if !SOCKNAL_SINGLE_FRAG_RX
- struct page *kss_rx_scratch_pgs[LNET_MAX_IOV];
+ struct page *kss_rx_scratch_pgs[LNET_MAX_IOV];
#endif
#if !SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_SINGLE_FRAG_RX
- struct iovec kss_scratch_iov[LNET_MAX_IOV];
+ struct iovec kss_scratch_iov[LNET_MAX_IOV];
#endif
} ksock_sched_t;
-typedef struct
-{
- unsigned int ksni_valid:1; /* been set yet? */
- unsigned int ksni_bound:1; /* bound to a cpu yet? */
- unsigned int ksni_sched:6; /* which scheduler (assumes < 64) */
-} ksock_irqinfo_t;
+struct ksock_sched_info {
+ int ksi_nthreads_max; /* max allowed threads */
+ int ksi_nthreads; /* number of threads */
+ int ksi_cpt; /* CPT id */
+ ksock_sched_t *ksi_scheds; /* array of schedulers */
+};
+
+#define KSOCK_CPT_SHIFT 16
+#define KSOCK_THREAD_ID(cpt, sid) (((cpt) << KSOCK_CPT_SHIFT) | (sid))
+#define KSOCK_THREAD_CPT(id) ((id) >> KSOCK_CPT_SHIFT)
+#define KSOCK_THREAD_SID(id) ((id) & ((1UL << KSOCK_CPT_SHIFT) - 1))
typedef struct /* in-use interface */
{
- __u32 ksni_ipaddr; /* interface's IP address */
- __u32 ksni_netmask; /* interface's network mask */
- int ksni_nroutes; /* # routes using (active) */
- int ksni_npeers; /* # peers using (passive) */
- char ksni_name[16]; /* interface name */
+ __u32 ksni_ipaddr; /* interface's IP address */
+ __u32 ksni_netmask; /* interface's network mask */
+ int ksni_nroutes; /* # routes using (active) */
+ int ksni_npeers; /* # peers using (passive) */
+ char ksni_name[IFNAMSIZ]; /* interface name */
} ksock_interface_t;
typedef struct
{
- int *ksnd_timeout; /* "stuck" socket timeout (seconds) */
+ /* "stuck" socket timeout (seconds) */
+ int *ksnd_timeout;
+ /* # scheduler threads in each pool while starting */
+ int *ksnd_nscheds;
int *ksnd_nconnds; /* # connection daemons */
int *ksnd_nconnds_max; /* max # connection daemons */
int *ksnd_min_reconnectms; /* first connection retry after (ms)... */
typedef struct
{
- __u64 ksnn_incarnation; /* my epoch */
- cfs_spinlock_t ksnn_lock; /* serialise */
- int ksnn_npeers; /* # peers */
- int ksnn_shutdown; /* shutting down? */
- int ksnn_ninterfaces; /* IP interfaces */
- ksock_interface_t ksnn_interfaces[LNET_MAX_INTERFACES];
+ __u64 ksnn_incarnation; /* my epoch */
+ spinlock_t ksnn_lock; /* serialise */
+ cfs_list_t ksnn_list; /* chain on global list */
+ int ksnn_npeers; /* # peers */
+ int ksnn_shutdown; /* shutting down? */
+ int ksnn_ninterfaces; /* IP interfaces */
+ ksock_interface_t ksnn_interfaces[LNET_MAX_INTERFACES];
} ksock_net_t;
/** connd timeout */
typedef struct
{
- int ksnd_init; /* initialisation state */
- int ksnd_nnets; /* # networks set up */
-
- cfs_rwlock_t ksnd_global_lock; /* stabilize peer/conn ops */
- cfs_list_t *ksnd_peers; /* hash table of all my known peers */
- int ksnd_peer_hash_size; /* size of ksnd_peers */
-
- int ksnd_nthreads; /* # live threads */
- int ksnd_shuttingdown; /* tell threads to exit */
- int ksnd_nschedulers; /* # schedulers */
- ksock_sched_t *ksnd_schedulers; /* their state */
+ int ksnd_init; /* initialisation state */
+ int ksnd_nnets; /* # networks set up */
+ cfs_list_t ksnd_nets; /* list of nets */
+ /* stabilize peer/conn ops */
+ rwlock_t ksnd_global_lock;
+ /* hash table of all my known peers */
+ cfs_list_t *ksnd_peers;
+ int ksnd_peer_hash_size; /* size of ksnd_peers */
+
+ int ksnd_nthreads; /* # live threads */
+ int ksnd_shuttingdown; /* tell threads to exit */
+ /* schedulers information */
+ struct ksock_sched_info **ksnd_sched_info;
cfs_atomic_t ksnd_nactive_txs; /* #active txs */
cfs_list_t ksnd_enomem_conns; /* conns to retry: reaper_lock*/
cfs_waitq_t ksnd_reaper_waitq; /* reaper sleeps here */
cfs_time_t ksnd_reaper_waketime;/* when reaper will wake */
- cfs_spinlock_t ksnd_reaper_lock; /* serialise */
+ spinlock_t ksnd_reaper_lock; /* serialise */
int ksnd_enomem_tx; /* test ENOMEM sender */
int ksnd_stall_tx; /* test sluggish sender */
long ksnd_connd_starting_stamp;
/** # running connd */
unsigned ksnd_connd_running;
- cfs_spinlock_t ksnd_connd_lock; /* serialise */
-
- cfs_list_t ksnd_idle_noop_txs; /* list head for freed noop tx */
- cfs_spinlock_t ksnd_tx_lock; /* serialise, NOT safe in g_lock */
+ spinlock_t ksnd_connd_lock; /* serialise */
- ksock_irqinfo_t ksnd_irqinfo[CFS_NR_IRQS];/* irq->scheduler lookup */
+ cfs_list_t ksnd_idle_noop_txs; /* list head for freed noop tx */
+ spinlock_t ksnd_tx_lock; /* serialise, g_lock unsafe */
} ksock_nal_data_t;
__u32 ksnc_myipaddr; /* my IP */
__u32 ksnc_ipaddr; /* peer's IP */
int ksnc_port; /* peer's port */
- int ksnc_type:3; /* type of connection, should be signed value */
- int ksnc_closing:1; /* being shut down */
- int ksnc_flip:1; /* flip or not, only for V2.x */
- int ksnc_zc_capable:1; /* enable to ZC */
+ signed int ksnc_type:3; /* type of connection,
+ * should be signed value */
+ unsigned int ksnc_closing:1; /* being shut down */
+ unsigned int ksnc_flip:1; /* flip or not, only for V2.x */
+ unsigned int ksnc_zc_capable:1; /* enable to ZC */
struct ksock_proto *ksnc_proto; /* protocol for the connection */
/* reader */
cfs_list_t ksnp_conns; /* all active connections */
cfs_list_t ksnp_routes; /* routes */
cfs_list_t ksnp_tx_queue; /* waiting packets */
- cfs_spinlock_t ksnp_lock; /* serialize, NOT safe in g_lock */
+ spinlock_t ksnp_lock; /* serialize, g_lock unsafe */
cfs_list_t ksnp_zc_req_list; /* zero copy requests wait for ACK */
cfs_time_t ksnp_send_keepalive; /* time to send keepalive */
lnet_ni_t *ksnp_ni; /* which network */
{
int rc = -ESHUTDOWN;
- cfs_read_lock (&ksocknal_data.ksnd_global_lock);
- if (!conn->ksnc_closing) {
- LASSERT (cfs_atomic_read(&conn->ksnc_sock_refcount) > 0);
- cfs_atomic_inc(&conn->ksnc_sock_refcount);
- rc = 0;
- }
- cfs_read_unlock (&ksocknal_data.ksnd_global_lock);
+ read_lock(&ksocknal_data.ksnd_global_lock);
+ if (!conn->ksnc_closing) {
+ LASSERT(cfs_atomic_read(&conn->ksnc_sock_refcount) > 0);
+ cfs_atomic_inc(&conn->ksnc_sock_refcount);
+ rc = 0;
+ }
+ read_unlock(&ksocknal_data.ksnd_global_lock);
return (rc);
}
int error);
extern void ksocknal_notify (lnet_ni_t *ni, lnet_nid_t gw_nid, int alive);
extern void ksocknal_query (struct lnet_ni *ni, lnet_nid_t nid, cfs_time_t *when);
-extern int ksocknal_thread_start (int (*fn)(void *arg), void *arg);
+extern int ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name);
extern void ksocknal_thread_fini (void);
extern void ksocknal_launch_all_connections_locked (ksock_peer_t *peer);
extern ksock_route_t *ksocknal_find_connectable_route_locked (ksock_peer_t *peer);
extern void ksocknal_lib_set_callback(cfs_socket_t *sock, ksock_conn_t *conn);
extern void ksocknal_lib_reset_callback(cfs_socket_t *sock, ksock_conn_t *conn);
extern void ksocknal_lib_push_conn (ksock_conn_t *conn);
-extern void ksocknal_lib_bind_irq (unsigned int irq);
extern int ksocknal_lib_get_conn_addrs (ksock_conn_t *conn);
-extern unsigned int ksocknal_lib_sock_irq (cfs_socket_t *sock);
extern int ksocknal_lib_setup_sock (cfs_socket_t *so);
extern int ksocknal_lib_send_iov (ksock_conn_t *conn, ksock_tx_t *tx);
extern int ksocknal_lib_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx);