[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [linux-2.6.18-xen] [IA64] Avoid allocating memory in interrupt context
# HG changeset patch # User Alex Williamson <alex.williamson@xxxxxx> # Date 1188326447 21600 # Node ID 72f2e9c1302da86348e88330913b790b15e9ec16 # Parent 057b47cada5c42a934c320f95863af2a6f031522 [IA64] Avoid allocating memory in interrupt context Allocate xencomm_handle in IA64_LOG_ALLOCATE instead of allocating each time. Signed-off-by: Kazuhiro Suzuki <kaz@xxxxxxxxxxxxxx> --- arch/ia64/kernel/mca.c | 22 ++++++++++++++++++++++ arch/ia64/kernel/salinfo.c | 32 ++++++++++++++++++++++++++++++++ include/asm-ia64/sal.h | 25 ++++++++++++++++++++----- 3 files changed, 74 insertions(+), 5 deletions(-) diff -r 057b47cada5c -r 72f2e9c1302d arch/ia64/kernel/mca.c --- a/arch/ia64/kernel/mca.c Thu Aug 23 15:18:40 2007 -0600 +++ b/arch/ia64/kernel/mca.c Tue Aug 28 12:40:47 2007 -0600 @@ -160,11 +160,33 @@ typedef struct ia64_state_log_s static ia64_state_log_t ia64_state_log[IA64_MAX_LOG_TYPES]; +#ifdef CONFIG_XEN +DEFINE_SPINLOCK(ia64_mca_xencomm_lock); +LIST_HEAD(ia64_mca_xencomm_list); + +#define IA64_MCA_XENCOMM_ALLOCATE(rec, desc) \ + if (is_running_on_xen()) { \ + ia64_mca_xencomm_t *entry; \ + entry = alloc_bootmem(sizeof(ia64_mca_xencomm_t)); \ + entry->record = rec; \ + entry->handle = desc; \ + list_add(&entry->list, &ia64_mca_xencomm_list); \ + } +#define IA64_LOG_ALLOCATE(it, size) \ + {ia64_err_rec_t *rec; \ + ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)] = rec = \ + (ia64_err_rec_t *)alloc_bootmem(size); \ + IA64_MCA_XENCOMM_ALLOCATE(rec, xencomm_map(rec, size)); \ + ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)] = rec = \ + (ia64_err_rec_t *)alloc_bootmem(size); \ + IA64_MCA_XENCOMM_ALLOCATE(rec, xencomm_map(rec, size));} +#else #define IA64_LOG_ALLOCATE(it, size) \ {ia64_state_log[it].isl_log[IA64_LOG_CURR_INDEX(it)] = \ (ia64_err_rec_t *)alloc_bootmem(size); \ ia64_state_log[it].isl_log[IA64_LOG_NEXT_INDEX(it)] = \ (ia64_err_rec_t *)alloc_bootmem(size);} +#endif #define IA64_LOG_LOCK_INIT(it) spin_lock_init(&ia64_state_log[it].isl_lock) #define IA64_LOG_LOCK(it) spin_lock_irqsave(&ia64_state_log[it].isl_lock, s) #define IA64_LOG_UNLOCK(it) spin_unlock_irqrestore(&ia64_state_log[it].isl_lock,s) diff -r 057b47cada5c -r 72f2e9c1302d arch/ia64/kernel/salinfo.c --- a/arch/ia64/kernel/salinfo.c Thu Aug 23 15:18:40 2007 -0600 +++ b/arch/ia64/kernel/salinfo.c Tue Aug 28 12:40:47 2007 -0600 @@ -375,6 +375,20 @@ salinfo_log_open(struct inode *inode, st data->open = 0; return -ENOMEM; } +#ifdef CONFIG_XEN + if (is_running_on_xen()) { + ia64_mca_xencomm_t *entry; + unsigned long flags; + + entry = vmalloc(sizeof(ia64_mca_xencomm_t)); + entry->record = data->log_buffer; + entry->handle = xencomm_map(data->log_buffer, + ia64_sal_get_state_info_size(data->type)); + spin_lock_irqsave(&ia64_mca_xencomm_lock, flags); + list_add(&entry->list, &ia64_mca_xencomm_list); + spin_unlock_irqrestore(&ia64_mca_xencomm_lock, flags); + } +#endif return 0; } @@ -386,6 +400,24 @@ salinfo_log_release(struct inode *inode, struct salinfo_data *data = entry->data; if (data->state == STATE_NO_DATA) { +#ifdef CONFIG_XEN + if (is_running_on_xen()) { + struct list_head *pos, *n; + unsigned long flags; + + spin_lock_irqsave(&ia64_mca_xencomm_lock, flags); + list_for_each_safe(pos, n, &ia64_mca_xencomm_list) { + ia64_mca_xencomm_t *entry; + + entry = list_entry(pos, ia64_mca_xencomm_t, list); + if (entry->record == data->log_buffer) { + list_del(&entry->list); + vfree(entry); + } + } + spin_unlock_irqrestore(&ia64_mca_xencomm_lock, flags); + } +#endif vfree(data->log_buffer); vfree(data->oemdata); data->log_buffer = NULL; diff -r 057b47cada5c -r 72f2e9c1302d include/asm-ia64/sal.h --- a/include/asm-ia64/sal.h Thu Aug 23 15:18:40 2007 -0600 +++ b/include/asm-ia64/sal.h Tue Aug 28 12:40:47 2007 -0600 @@ -691,6 +691,13 @@ ia64_sal_clear_state_info (u64 sal_info_ */ #ifdef CONFIG_XEN static inline u64 ia64_sal_get_state_info_size (u64 sal_info_type); +typedef struct ia64_mca_xencomm_t { + void *record; + struct xencomm_handle *handle; + struct list_head list; +} ia64_mca_xencomm_t; +extern struct list_head ia64_mca_xencomm_list; +extern spinlock_t ia64_mca_xencomm_lock; #endif static inline u64 @@ -699,16 +706,24 @@ ia64_sal_get_state_info (u64 sal_info_ty struct ia64_sal_retval isrv; #ifdef CONFIG_XEN if (is_running_on_xen()) { - struct xencomm_handle *desc; - - desc = xencomm_map(sal_info, - ia64_sal_get_state_info_size(sal_info_type)); + ia64_mca_xencomm_t *entry; + struct xencomm_handle *desc = NULL; + unsigned long flags; + + spin_lock_irqsave(&ia64_mca_xencomm_lock, flags); + list_for_each_entry(entry, &ia64_mca_xencomm_list, list) { + if (entry->record == sal_info) { + desc = entry->handle; + break; + } + } + spin_unlock_irqrestore(&ia64_mca_xencomm_lock, flags); + if (desc == NULL) return 0; SAL_CALL_REENTRANT(isrv, SAL_GET_STATE_INFO, sal_info_type, 0, desc, 0, 0, 0, 0); - xencomm_free(desc); } else #endif SAL_CALL_REENTRANT(isrv, SAL_GET_STATE_INFO, sal_info_type, 0, _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |