|
|
|
Re: [PATCH 3/4] zsmalloc use zs_handle instead of void * | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
|
On 5/10/12 10:02 AM, Konrad Rzeszutek Wilk wrote:
On Thu, May 10, 2012 at 11:03:19AM +0900, Minchan Kim wrote:On 05/10/2012 05:19 AM, Greg Kroah-Hartman wrote:On Fri, May 04, 2012 at 11:24:54AM +0900, Minchan Kim wrote:On 05/04/2012 12:23 AM, Seth Jennings wrote:On 05/03/2012 08:32 AM, Nitin Gupta wrote:On 5/3/12 2:40 AM, Minchan Kim wrote:We should use zs_handle instead of void * to avoid any confusion. Without this, users may just treat zs_malloc return value as a pointer and try to deference it. Cc: Dan Magenheimer<dan.magenheimer@xxxxxxxxxx> Cc: Konrad Rzeszutek Wilk<konrad.wilk@xxxxxxxxxx> Signed-off-by: Minchan Kim<minchan@xxxxxxxxxx> --- drivers/staging/zcache/zcache-main.c | 8 ++++---- drivers/staging/zram/zram_drv.c | 8 ++++---- drivers/staging/zram/zram_drv.h | 2 +- drivers/staging/zsmalloc/zsmalloc-main.c | 28 ++++++++++++++-------------- drivers/staging/zsmalloc/zsmalloc.h | 15 +++++++++++---- 5 files changed, 34 insertions(+), 27 deletions(-)This was a long pending change. Thanks!The reason I hadn't done it before is that it introduces a checkpatch warning: WARNING: do not add new typedefs #303: FILE: drivers/staging/zsmalloc/zsmalloc.h:19: +typedef void * zs_handle;Yes. I did it but I think we are (a) of chapter 5: Typedefs in Documentation/CodingStyle. (a) totally opaque objects (where the typedef is actively used to _hide_ what the object is). No?No. Don't add new typedefs to the kernel. Just use a structure if you need to.I tried it but failed because there were already tightly coupling between [zcache|zram] and zsmalloc. They already knows handle's internal well so they used it as pointer, even zcache keeps handle's value as some key in tmem_put and tmem_get AFAIK, ramster also will use zsmalloc sooner or later and add more coupling codes. Sigh. Please fix it as soon as possible. Dan, Seth Any ideas?struct zs { void *ptr; }; And pass that structure around?
A minor problem is that we store this handle value in a radix tree node. If we wrap it as a struct, then we will not be able to store it directly in the node -- the node will have to point to a 'struct zs'. This will unnecessarily waste sizeof(void *) for every object stored.
We could 'memcpy' struct zs to a void * and then store that directly in the radix node but not sure if that would be less ugly than just returning the handle as a void * as is done currently.
Thanks, Nitin -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[Other Archives] [Linux Kernel Newbies] [Linux Driver Development] [Fedora Kernel] [Linux Kernel Testers] [Linux SH] [Linux Omap] [Linux Kbuild] [Linux Tape] [Linux Input] [Linux Kernel Janitors] [Linux Kernel Packagers] [Linux Doc] [Linux Man Pages] [Linux API] [Linux Memory Management] [Linux Modules] [Linux Standards] [Kernel Announce] [Netdev] [Git] [Linux PCI] Linux CAN Development [Linux I2C] [Linux RDMA] [Linux NUMA] [Netfilter] [Netfilter Devel] [SELinux] [Bugtraq] [FIO] [Linux Perf Users] [Linux Serial] [Linux PPP] [Linux ISDN] [Linux Next] [Kernel Stable Commits] [Linux Tip Commits] [Kernel MM Commits] [Linux Security Module] [AutoFS] [Filesystem Development] [Ext3 Filesystem] [Linux bcache] [Ext4 Filesystem] [Linux BTRFS] [Linux CEPH Filesystem] [Linux XFS] [XFS] [Linux NFS] [Linux CIFS] [Ecryptfs] [Linux NILFS] [Linux Cachefs] [Reiser FS] [Initramfs] [Linux FB Devel] [Linux OpenGL] [DRI Devel] [Fastboot] [Linux RT Users] [Linux RT Stable] [eCos] [Corosync] [Linux Clusters] [LVS Devel] [Hot Plug] [Linux Virtualization] [KVM] [KVM PPC] [KVM ia64] [Linux Containers] [Linux Hexagon] [Linux Cgroups] [Util Linux] [Wireless] [Linux Bluetooth] [Bluez Devel] [Ethernet Bridging] [Embedded Linux] [Barebox] [Linux MMC] [Linux IIO] [Sparse] [Smatch] [Linux Arch] [x86 Platform Driver] [Linux ACPI] [Linux IBM ACPI] [LM Sensors] [CPU Freq] [Linux Power Management] [Linmodems] [Linux DCCP] [Linux SCTP] [ALSA Devel] [Linux USB] [Linux PA RISC] [Linux Samsung SOC] [MIPS Linux] [IBM S/390 Linux] [ARM Linux] [ARM Kernel] [ARM MSM] [Tegra Devel] [Sparc Linux] [Linux Security] [Linux Sound] [Linux Media] [Video 4 Linux] [Linux IRDA Users] [Linux for the blind] [Linux RAID] [Linux ATA RAID] [Device Mapper] [Linux SCSI] [SCSI Target Devel] [Linux SCSI Target Infrastructure] [Linux IDE] [Linux SMP] [Linux AXP] [Linux Alpha] [Linux M68K] [Linux ia64] [Linux 8086] [Linux x86_64] [Linux Config] [Linux Apps] [Linux MSDOS] [Linux X.25] [Linux Crypto] [DM Crypt] [Linux Trace Users] [Linux Btrace] [Linux Watchdog] [Utrace Devel] [Linux C Programming] [Linux Assembly] [Dash] [DWARVES] [Hail Devel] [Linux Kernel Debugger] [Linux gcc] [Gcc Help] [X.Org] [Wine]
![]() |
![]() |
[Older Kernel Discussion] [Yosemite National Park Forum] [Large Format Photos] [Gimp] [Yosemite Photos] [Stuff]