From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1952822AbdDZGPS (ORCPT ); Wed, 26 Apr 2017 02:15:18 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34770 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033861AbdDZGPK (ORCPT ); Wed, 26 Apr 2017 02:15:10 -0400 Date: Wed, 26 Apr 2017 15:14:57 +0900 From: Sergey Senozhatsky To: Joonsoo Kim Cc: Sergey Senozhatsky , Andrew Morton , Minchan Kim , Sergey Senozhatsky , linux-kernel@vger.kernel.org, kernel-team@lge.com Subject: Re: [PATCH v4 2/4] zram: implement deduplication in zram Message-ID: <20170426061457.GF673@jagdpanzerIV.localdomain> References: <1493167946-10936-1-git-send-email-iamjoonsoo.kim@lge.com> <1493167946-10936-3-git-send-email-iamjoonsoo.kim@lge.com> <20170426042826.GD673@jagdpanzerIV.localdomain> <20170426060816.GD29773@js1304-desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170426060816.GD29773@js1304-desktop> User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (04/26/17 15:08), Joonsoo Kim wrote: > > > +struct zram_hash { > > > + spinlock_t lock; > > > + struct rb_root rb_root; > > > }; > > > > just a note. > > > > we can easily have N CPUs spinning on ->lock for __zram_dedup_get() lookup, > > which can invole a potentially slow zcomp_decompress() [zlib, for example, > > with 64k pages] and memcmp(). the larger PAGE_SHIFT is, the more serialized > > IOs become. in theory, at least. > > > > CPU0 CPU1 ... CPUN > > > > __zram_bvec_write() __zram_bvec_write() __zram_bvec_write() > > zram_dedup_find() zram_dedup_find() zram_dedup_find() > > spin_lock(&hash->lock); > > spin_lock(&hash->lock); spin_lock(&hash->lock); > > __zram_dedup_get() > > zcomp_decompress() > > ... > > > > > > so may be there is a way to use read-write lock instead on spinlock for hash > > and reduce write/read IO serialization. > > In fact, dedup release hash->lock before doing zcomp_decompress(). So, > above contention cannot happen. oh, my bad. you are right. somehow I didn't spot the unlock. -ss