[Devel] Re: [PATCH] Save and restore the [compat_]robust_list member of the task struct.
Nathan Lynch
ntl at pobox.com
Wed Jul 15 12:15:18 PDT 2009
Nathan Lynch <ntl at pobox.com> writes:
> Matt Helsley <matthltc at us.ibm.com> writes:
>> diff --git a/include/linux/futex.h b/include/linux/futex.h
>> index 4326f81..934cf98 100644
>> --- a/include/linux/futex.h
>> +++ b/include/linux/futex.h
>> @@ -185,9 +185,46 @@ union futex_key {
>> #define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } }
>>
>> #ifdef CONFIG_FUTEX
>> +extern long do_set_robust_list(struct robust_list_head __user *head, size_t len);
>> extern void exit_robust_list(struct task_struct *curr);
>> extern void exit_pi_state_list(struct task_struct *curr);
>> extern int futex_cmpxchg_enabled;
>> +
>> +#ifdef CONFIG_CHECKPOINT
>> +#include <linux/checkpoint_hdr.h>
>> +
>> +static inline void save_task_robust_futex_list(struct ckpt_hdr_task *h,
>> + struct task_struct *t)
>> +{
>> + /*
>> + * These are __user pointers and thus can be saved without
>> + * the objhash.
>> + */
>> + h->robust_futex_list = (unsigned long)t->robust_list;
>> + h->robust_futex_head_len = sizeof(*t->robust_list);
>> +#ifdef CONFIG_COMPAT
>> + h->compat_robust_futex_list = ptr_to_compat(t->compat_robust_list);
>> + h->compat_robust_futex_head_len = sizeof(*t->compat_robust_list);
>> +#endif
>> +}
>> +
>> +static inline void restore_task_robust_futex_list(struct ckpt_hdr_task *h)
>> +{
>> + /* Since we restore the memory map the address remains the same and
>> + * this is safe. This is the same as [compat_]sys_set_robust_list() */
>> + if (h->robust_futex_list) {
>> + struct robust_list_head __user *rfl = (void __user *)(unsigned long)h->robust_futex_list;
>> + do_set_robust_list(rfl, h->robust_futex_head_len);
>> + }
>> +#ifdef CONFIG_COMPAT
>> + if (h->compat_robust_futex_list) {
>> + struct compat_robust_list_head __user *crfl = compat_ptr(h->compat_robust_futex_list);
>> + do_compat_set_robust_list(crfl, h->compat_robust_futex_head_len);
>> + }
>> +#endif
>> +}
>> +#endif /* CONFIG_CHECKPOINT */
>> +
>> #else
>> static inline void exit_robust_list(struct task_struct *curr)
>> {
>> @@ -195,6 +232,15 @@ static inline void exit_robust_list(struct task_struct *curr)
>> static inline void exit_pi_state_list(struct task_struct *curr)
>> {
>> }
>> +#ifdef CONFIG_CHECKPOINT
>> +static inline void save_task_robust_futex_list(struct ckpt_hdr_task *h,
>> + struct task_struct *t)
>> +{
>> +}
>> +static inline void restore_task_robust_futex_list(struct ckpt_hdr_task *h)
>> +{
>> +}
>> +#endif /* CONFIG_CHECKPOINT */
>> #endif
>> #endif /* __KERNEL__ */
>>
>
> powerpc build with CONFIG_CHECKPOINT=y fails. I suspect any
> CONFIG_COMPAT=y build fails?
>
> In file included from kernel/fork.c:42:
> include/linux/futex.h: In function ‘save_task_robust_futex_list’:
> include/linux/futex.h:206: error: implicit declaration of function ‘ptr_to_compat’
> include/linux/futex.h:207: error: dereferencing pointer to incomplete type
> include/linux/futex.h: In function ‘restore_task_robust_futex_list’:
> include/linux/futex.h:221: error: implicit declaration of function ‘compat_ptr’
> include/linux/futex.h:221: warning: initialization makes pointer from integer without a cast
> include/linux/futex.h:222: error: implicit declaration of function ‘do_compat_set_robust_list’
>
> fix:
>
> diff --git a/include/linux/futex.h b/include/linux/futex.h
> index 934cf98..f40a9bf 100644
> --- a/include/linux/futex.h
> +++ b/include/linux/futex.h
> @@ -3,6 +3,7 @@
>
> #include <linux/compiler.h>
> #include <linux/types.h>
> +#include <linux/compat.h>
>
> struct inode;
> struct mm_struct;
Sigh... this breaks headers_check:
linux-2.6.git/usr/include/linux/futex.h:6: included file 'linux/compat.h' is not exported
I think we could sidestep this mess by putting the futex-related
checkpoint functions in futex.c instead of making them inlines in an
exported header.
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
More information about the Devel
mailing list