From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751159AbdAQRYu convert rfc822-to-8bit (ORCPT ); Tue, 17 Jan 2017 12:24:50 -0500 Received: from mga02.intel.com ([134.134.136.20]:45733 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750941AbdAQRYs (ORCPT ); Tue, 17 Jan 2017 12:24:48 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,245,1477983600"; d="scan'208";a="214427675" From: "Chen, Tim C" To: Michal Hocko , "Huang, Ying" CC: Andrew Morton , "Hansen, Dave" , "ak@linux.intel.com" , "Lu, Aaron" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Hugh Dickins , Shaohua Li , Minchan Kim , Rik van Riel , Andrea Arcangeli , "Kirill A . Shutemov" , Vladimir Davydov , Johannes Weiner , Hillf Danton , Christian Borntraeger , Jonathan Corbet Subject: RE: [Update][PATCH v5 7/9] mm/swap: Add cache for swap slots allocation Thread-Topic: [Update][PATCH v5 7/9] mm/swap: Add cache for swap slots allocation Thread-Index: AQHScG09qQVPhF5qu0C4ttXgXntMFqE8+s4A///vYEA= Date: Tue, 17 Jan 2017 17:24:15 +0000 Message-ID: <045D8A5597B93E4EBEDDCBF1FC15F50935C9F523@fmsmsx104.amr.corp.intel.com> References: <35de301a4eaa8daa2977de6e987f2c154385eb66.1484082593.git.tim.c.chen@linux.intel.com> <87tw8ymm2z.fsf_-_@yhuang-dev.intel.com> <20170117101631.GG19699@dhcp22.suse.cz> In-Reply-To: <20170117101631.GG19699@dhcp22.suse.cz> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTdjZjA0M2EtY2FiNS00NmQ2LWJlNGItOTUwZGQxMTFkMTkzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6Ijk1dng2Q20rRElWSHV1ek9DR3h3WmdFMFVwK044TWNpQU5Ca0YwZDhBUnc9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.1.200.108] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > + /* > > + * Preemption need to be turned on here, because we may sleep > > + * in refill_swap_slots_cache(). But it is safe, because > > + * accesses to the per-CPU data structure are protected by a > > + * mutex. > > + */ > > the comment doesn't really explain why it is safe. THere are other users > which are not using the lock. E.g. just look at free_swap_slot above. > How can > cache->slots_ret[cache->n_ret++] = entry; be safe wrt. > pentry = &cache->slots[cache->cur++]; > entry = *pentry; > > Both of them might touch the same slot, no? Btw. I would rather prefer this > would be a follow up fix with the trace and the detailed explanation. > The cache->slots_ret is protected by cache->free_lock and cache->slots is protected by cache->free_lock. They are two separate structures, one for caching the slots returned and one for caching the slots allocated. So they do no touch the same slots. We'll update the comments so it is clearer. Sure. We can issue a follow up fix on top of the current patchset. Thanks. Tim