Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp715066imb; Fri, 1 Mar 2019 12:00:50 -0800 (PST) X-Google-Smtp-Source: APXvYqyV2j80E4/rL1Ts2kQD8xcX0tCvwnPwOV/WSFoi7AkF+Uo66d5O5cQjlc7oo3R8A3pje9m6 X-Received: by 2002:a63:305:: with SMTP id 5mr6555326pgd.57.1551470449778; Fri, 01 Mar 2019 12:00:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551470449; cv=none; d=google.com; s=arc-20160816; b=PJImbEiBym6+0qWmNbdoDPgeLmdn0IikTv7CDXW7yOVcffT4J1bBtdo8jS5oump+oZ xSBj/KFQIuSPqAVHn2s5ixIogagmbY4jYOM4UK/XY4mWRFoJtR59oT3MCatvtetBQAY/ VnybdkiCqXxHdMNTSC4tEF7Bro94pwWOmam9YVYtmXeFuZn6GQ3lQY0tqI2PZuRi3SAV U9sjLU6lU7vUFgrlOWpquWf5poleOa0zRwlRy4dBDLhe7ZSiNpPzYC/Hp+f6QVscAtJa 7rcAS5neX0pRnQCtG7QCmbYUx+gpOYMPoDai/ywifx1+e1sf+vAt1/De4bb7nelPf5Re n+JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=iet7hguJ74vBzlUc4/t0rTAEzUcMPS5XRiat49LTLdU=; b=YbK8OsJpZw9o1FMPHJ1rsqrfAjTus4wnlyPEsavKVx2r9a8wQy9aCbHi3+rVH1RCaJ wSDdPMxtZQKUUuQWHd3od6M4Df6WWzYbMNVQDp696TTAeV9LKPVfU640qqoVHgeCMUHe I+ZpL6P/yWY1g6FVisq0W7ba0IdxbE0e8krBVfuVZxP671P/P3INoD2EzAGKAI2E4/o8 dMo2tsvSaY07fnXb+LxhYjMExRW+4jD9XlRGhcvmu9giZjhRpmSUvSB/GOoCaVsVjgdb /se9nV8B1yw5kJTx49BbZmskgP07R7p/chBV7fKbBkxYb7NHIX7dZcWMbHHPATteQj3K kq8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=fc1D85Qh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cg7si22980931plb.127.2019.03.01.12.00.33; Fri, 01 Mar 2019 12:00:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=fc1D85Qh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726051AbfCAT6m (ORCPT + 99 others); Fri, 1 Mar 2019 14:58:42 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:5598 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725905AbfCAT6m (ORCPT ); Fri, 1 Mar 2019 14:58:42 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 01 Mar 2019 11:58:50 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 01 Mar 2019 11:58:41 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 01 Mar 2019 11:58:41 -0800 Received: from [10.110.48.28] (10.124.1.5) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 1 Mar 2019 19:58:41 +0000 Subject: Re: [PATCH v2 2/4] mm: remove zone_lru_lock() function access ->lru_lock directly To: Andrey Ryabinin , Andrew Morton CC: Johannes Weiner , Vlastimil Babka , Rik van Riel , , , Michal Hocko , Mel Gorman References: <20190228083329.31892-1-aryabinin@virtuozzo.com> <20190228083329.31892-2-aryabinin@virtuozzo.com> <44ffadb4-4235-76c9-332f-680dda5da521@nvidia.com> <186bf66b-fec5-a614-3ffd-64b8d7660fe5@virtuozzo.com> From: John Hubbard X-Nvconfidentiality: public Message-ID: <1aac5881-0590-8c24-d963-1a7be86a7c43@nvidia.com> Date: Fri, 1 Mar 2019 11:58:40 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <186bf66b-fec5-a614-3ffd-64b8d7660fe5@virtuozzo.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8" Content-Language: en-US-large Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1551470330; bh=iet7hguJ74vBzlUc4/t0rTAEzUcMPS5XRiat49LTLdU=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=fc1D85Qh67XVnbF++2wghKnKz2r/XTZWPhZRYHcMwgialicSrayW/7fis6GLUxt3q nwDHzN11qXq8F+g92Z8hYbEa7zHCO4T73RWtBU4RPOE7q+QSZO//0eju/cigOiEftt BTErVRdvrONbuzpEpC0G8HMdzi31LmWkdXx+7df4oPyZVVitXAe+DwXJLd5fSSzBSB k8e+qDuTenbi8L4be+B3I/ky0Qv7mmYbP4CNbApDy2zivyxa9dEoqCZtXNoJQEQqBr M1enFdc5hBexsFfHUFiauKaYstoHRAffAfBXypVDMp7kqUO4sqNUYOwU2jVVA4QNgu 2AoVxJonVzYug== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/1/19 2:51 AM, Andrey Ryabinin wrote: > > > On 3/1/19 12:44 AM, John Hubbard wrote: >> On 2/28/19 12:33 AM, Andrey Ryabinin wrote: >>> We have common pattern to access lru_lock from a page pointer: >>> zone_lru_lock(page_zone(page)) >>> >>> Which is silly, because it unfolds to this: >>> &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)]->zone_pgdat->lru_lock >>> while we can simply do >>> &NODE_DATA(page_to_nid(page))->lru_lock >>> >> >> Hi Andrey, >> >> Nice. I like it so much that I immediately want to tweak it. :) >> >> >>> Remove zone_lru_lock() function, since it's only complicate things. >>> Use 'page_pgdat(page)->lru_lock' pattern instead. >> >> Here, I think the zone_lru_lock() is actually a nice way to add >> a touch of clarity at the call sites. How about, see below: >> >> [snip] >> >>> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h >>> index 2fd4247262e9..22423763c0bd 100644 >>> --- a/include/linux/mmzone.h >>> +++ b/include/linux/mmzone.h >>> @@ -788,10 +788,6 @@ typedef struct pglist_data { >>> >>> #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) >>> #define node_end_pfn(nid) pgdat_end_pfn(NODE_DATA(nid)) >>> -static inline spinlock_t *zone_lru_lock(struct zone *zone) >>> -{ >>> - return &zone->zone_pgdat->lru_lock; >>> -} >>> >> >> Instead of removing that function, let's change it, and add another >> (since you have two cases: either a page* or a pgdat* is available), >> and move it to where it can compile, like this: >> >> >> diff --git a/include/linux/mm.h b/include/linux/mm.h >> index 80bb6408fe73..cea3437f5d68 100644 >> --- a/include/linux/mm.h >> +++ b/include/linux/mm.h >> @@ -1167,6 +1167,16 @@ static inline pg_data_t *page_pgdat(const struct page *page) >> return NODE_DATA(page_to_nid(page)); >> } >> >> +static inline spinlock_t *zone_lru_lock(pg_data_t *pgdat) >> +{ >> + return &pgdat->lru_lock; >> +} >> + > > > I don't think wrapper for a simple plain access to the struct member is reasonable. > Besides, there are plenty of "spin_lock(&pgdat->lru_lock)" even without this patch, > so for consistency reasons &pgdat->lru_lock seems like a better choice to me. > > Also "&pgdat->lru_lock" is just shorter than: > "node_lru_lock(pgdat)" > > > >> +static inline spinlock_t *zone_lru_lock_from_page(struct page *page) >> +{ >> + return zone_lru_lock(page_pgdat(page)); >> +} >> + > > I don't think such function would find any use. Usually lru_lock is taken > to perform some manipulations with page *and* pgdat, thus it's better to remember > page_pgdat(page) in local variable. > That's a good argument. thanks, -- John Hubbard NVIDIA