Re: [PATCH 5/8] trace_uprobe: Support SDT markers having reference count (semaphore)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 03/15/2018 08:31 PM, Oleg Nesterov wrote:
> On 03/13, Ravi Bangoria wrote:
>> +sdt_update_ref_ctr(struct mm_struct *mm, unsigned long vaddr, short d)
>> +{
>> +	void *kaddr;
>> +	struct page *page;
>> +	struct vm_area_struct *vma;
>> +	int ret = 0;
>> +	unsigned short orig = 0;
>> +
>> +	if (vaddr == 0)
>> +		return -EINVAL;
>> +
>> +	ret = get_user_pages_remote(NULL, mm, vaddr, 1,
>> +		FOLL_FORCE | FOLL_WRITE, &page, &vma, NULL);
>> +	if (ret <= 0)
>> +		return ret;
>> +
>> +	kaddr = kmap_atomic(page);
>> +	memcpy(&orig, kaddr + (vaddr & ~PAGE_MASK), sizeof(orig));
>> +	orig += d;
>> +	memcpy(kaddr + (vaddr & ~PAGE_MASK), &orig, sizeof(orig));
>> +	kunmap_atomic(kaddr);
> Hmm. Why memcpy? You could simply do
>
> 	kaddr = kmap_atomic();
> 	unsigned short *ptr = kaddr + (vaddr & ~PAGE_MASK);
> 	*ptr += d;
> 	kunmap_atomic();

Yes, that should work. Will change it.

Thanks for the review,
Ravi

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux