Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1455498ima; Wed, 24 Oct 2018 22:33:51 -0700 (PDT) X-Google-Smtp-Source: AJdET5e3i0JCh5edTF3rHL1WeoadSrI4hgasijBbq/JVcen7RC9u741wC4/JM5uEz87OkgCAAC/6 X-Received: by 2002:a62:7d81:: with SMTP id y123-v6mr136875pfc.245.1540445631682; Wed, 24 Oct 2018 22:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540445631; cv=none; d=google.com; s=arc-20160816; b=wH9BxUKfQ4NEWouX+PPH4DMBl1qhnusYybTRO4mEcLOHmNE49/KrXFRog2P8F+XLHs riPg8oR720Cuvcw1ux+9jTMm4YJwN2KBX7oxuo1Wl7Rs+wF9oSsBbVuo440tC4EoZxu1 CvJ3sr1V9VOj8TjpWeZGjNjlSL0o6OSydXrU+FmSPvzpkZMGpQ6yprOsDyCEvTOb6TJ+ APTohVFpESIiWJ5wrzsyvrMqgDVIgvadFgiUQ60WDvBaVXdTFozOqHQb05DMTvRlhToW YqVbZWlrbD5CPzBPGK2NRgVg6NszBOKjdFgtZ2XL6GV57Y0xR2AHi28Son4Bav631YxV 1scQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature; bh=AOWAiZq6uIGd/v7B3maknGGGhrXRJShgw45sUUpS8Ak=; b=VG5zK0bM3pWTkDcplOSCo/q7ni925KruMsFG9ee+3zrSFWX+jqGoT+OuK0v4/oGZdR RdbAdMEdsssXEEhTUE4C5c3Qsr5Rurg69Q/ypUuRLImXXiqBGAAjfr6aPAWExSilYJaK tm3fCzl1gWZ+o1z/rZ8LQphFh7wShTfqAi64eBC7T7q45BvMmEKija2GhipyvXQDtBsS ZvrCVaZP6Tg6UJttKdhRphYLPGFt5IAQamJkg+ORonmd3pgbYh2OnErztO5rJCM/bVgu a/pRb22/SMwWs5TWu0gIWZBFe4IchwQWelOupfsD55M1Vftuy+PmlSdYXAuL4IABx1qW rJOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=IuZcJ9mr; dkim=pass header.i=@codeaurora.org header.s=default header.b=UiIdugMf; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s61-v6si196666plb.309.2018.10.24.22.33.35; Wed, 24 Oct 2018 22:33:51 -0700 (PDT) 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=@codeaurora.org header.s=default header.b=IuZcJ9mr; dkim=pass header.i=@codeaurora.org header.s=default header.b=UiIdugMf; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727265AbeJYOCu (ORCPT + 99 others); Thu, 25 Oct 2018 10:02:50 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:59872 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726909AbeJYOCt (ORCPT ); Thu, 25 Oct 2018 10:02:49 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C582C602BA; Thu, 25 Oct 2018 05:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1540445502; bh=veWBQpMVpPklvc99nzVyn74lBus8U7yE6n+wgi2BPzA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IuZcJ9mrFSuXW46Vu5Kr0in5aiJh/YAz0OWKsgOMEkMk02/IVAsYy5ucqKMfwS1tf cKjjBK6yXaQrVd+5ySHQq2zzuLZAN6jTKW/LidLVOi4dfzXqVbF0FNgOr41lUwNd2u QUcLalYPb2UN78TX+fjfeJWw45jYKFozqAc3KRt0= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id B0ACF602BA; Thu, 25 Oct 2018 05:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1540445501; bh=veWBQpMVpPklvc99nzVyn74lBus8U7yE6n+wgi2BPzA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UiIdugMfGD4Lbjyh23pVXxbvK9cQyhOH84GeRHVfHHBFDptGDMf5MtmIp0l+bJD8O 8jIEXVNbSvrivin3/lFF/kvWnFMLTeBYcVgC8301mmqHcwRQvYNv/1I6TBZW1OGcbs Bd9MIqddEqOPHwud/TrYF09CUZoIWa0p5H/UyaHY= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 25 Oct 2018 11:01:41 +0530 From: Arun KS To: Julia Lawall Cc: Michal Hocko , Arun Sudhilal , linux-kernel@vger.kernel.org, linux-mm , Minchan Kim , Michal Hocko , Greg Kroah-Hartman , Andrew Morton Subject: Re: [PATCH] mm: convert totalram_pages, totalhigh_pages and managed_pages to atomic. In-Reply-To: References: <1540229092-25207-1-git-send-email-arunks@codeaurora.org> <20181022181122.GK18839@dhcp22.suse.cz> <20181023053359.GL18839@dhcp22.suse.cz> Message-ID: <9bd14fb3c0ce8ca9a33c33ce81e66037@codeaurora.org> X-Sender: arunks@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-10-23 11:43, Julia Lawall wrote: > On Tue, 23 Oct 2018, Michal Hocko wrote: > >> [Trimmed CC list + Julia - there is indeed no need to CC everybody >> maintain a >> file you are updating for the change like this] >> >> On Tue 23-10-18 10:16:51, Arun Sudhilal wrote: >> > On Mon, Oct 22, 2018 at 11:41 PM Michal Hocko wrote: >> > > >> > > On Mon 22-10-18 22:53:22, Arun KS wrote: >> > > > Remove managed_page_count_lock spinlock and instead use atomic >> > > > variables. >> > > >> > >> > Hello Michal, >> > > I assume this has been auto-generated. If yes, it would be better to >> > > mention the script so that people can review it and regenerate for >> > > comparision. Such a large change is hard to review manually. >> > >> > Changes were made partially with script. For totalram_pages and >> > totalhigh_pages, >> > >> > find dir -type f -exec sed -i >> > 's/totalram_pages/atomic_long_read(\&totalram_pages)/g' {} \; >> > find dir -type f -exec sed -i >> > 's/totalhigh_pages/atomic_long_read(\&totalhigh_pages)/g' {} \; >> > >> > For managed_pages it was mostly manual edits after using, >> > find mm/ -type f -exec sed -i >> > 's/zone->managed_pages/atomic_long_read(\&zone->managed_pages)/g' {} >> > \; >> >> I guess we should be able to use coccinelle for this kind of change >> and >> reduce the amount of manual intervention to absolute minimum. > > Coccinelle looks like it would be desirable, especially in case the > word > zone is not always used. > > Arun, please feel free to contact me if you want to try it and need > help. Hello Julia, I was able to come up .cocci for replacing managed_pages, @@ struct zone *z; @@ ( z->managed_pages = ... | - z->managed_pages + atomic_long_read(&z->managed_pages) ) @@ struct zone *z; expression e1; @@ - z->managed_pages = e1 + atomic_long_set(&z->managed_pages, e1) @@ expression e,e1; @@ - e->managed_pages += e1 + atomic_long_add(e1, &e->managed_pages) @@ expression z; @@ - z.managed_pages + atomic_long_read(&z.managed_pages) But I m not able to use same method for unsigned long variables(totalram_pages) @@ unsigned long totalram_pages; @@ ( totalram_pages = ... | -totalram_pages +atomic_long_read(&totalram_pages) ) This throws error, spatch test1.cocci mm/page_alloc.c init_defs_builtins: /usr/lib/coccinelle/standard.h HANDLING: mm/page_alloc.c previous modification: MINUS >>> atomic_long_read(&rule starting on line 1:totalram_pages) According to environment 1: rule starting on line 1.totalram_pages -> page_idx ^ (1 << order) current modification: MINUS >>> atomic_long_read(&rule starting on line 1:totalram_pages) According to environment 1: rule starting on line 1.totalram_pages -> page_idx Fatal error: exception Failure("rule starting on line 1: already tagged token: C code context File "mm/internal.h", line 175, column 8, charpos = 5368 around = 'page_idx', whole content = return page_idx ^ (1 << order);") Regards, Arun > > julia