Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp3897306ima; Tue, 23 Oct 2018 13:07:28 -0700 (PDT) X-Google-Smtp-Source: AJdET5et5QDytpP05pNcWhe1eF7jORn8otv0qAzbUl0WvV85O4fPZphSAOXqZl/YhuIqsXMR9A21 X-Received: by 2002:a65:4c8d:: with SMTP id m13-v6mr8182794pgt.83.1540325248008; Tue, 23 Oct 2018 13:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540325247; cv=none; d=google.com; s=arc-20160816; b=el3gtoxa4bydBYdUfZeYPQO9/ITNoqLRCzuJs14QTp6z8ileBGYkCS72bHqyGMIZyW N8/uaWfLgTwGO6nLpCTPuWKIePfZrT+zJOftiGGLZ+Z8ti2ja5bNwR5l3h0cwv9E2GzF sUavTE6Waj9JaeM2vVsYXZgTf9ObkC5pZLBaLspjxySILkCM6Fk+ZWKJFkBvHV+IDiBA E7vDWoMgwgtzbjwyPf0Bgj1OXVJmkvdUBQR/qEReEBIO/0+OK1y4IvYFCDuTgruS2yiv DUaJt8RlV2Eqzi+dGlOSdJjHAGvoGyg31zjN6sr5t9LAYGr1u9d5WlaH6NZV+gFZvDUu DEyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=4MCSMXG0/Rs9wIHCX+w1Qy6QE/zsrASHTckZZZ6XpL8=; b=ilLoIkwUZiSp2Wt20vB7epqZu5xHCg55NUyfhqiRk8U0waiugBOhq9yZvxctCBKIR9 CkU2RPMovK8dC4rkWCQeXFTRhJ5FqNvA94+JkOJR3PMjn9EPddkrhbVYfnsKaX5qpwtJ 7Vi4z4AObWuE76+xJR+/zf1O5dMCGXbFUDWpnBDCDEbYqBlBbOd6tQdoEx4AnPyKPduL V3kuJCHz7Clco5vyYQR8ZV6owVbt5mMJpcjbtW6BB4UcJDynZZ6XPvzRiYGHEpYUFham ihHsrP7ipyoWf9gbS0jXKeZJw+LOif5ue2FijQ/nFFMrpVXHUAk+Yis0jo5Up+ExpMJP 2xUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=B1arXYMO; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11-v6si2194976pgd.342.2018.10.23.13.07.10; Tue, 23 Oct 2018 13:07:27 -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=@chromium.org header.s=google header.b=B1arXYMO; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728758AbeJXE36 (ORCPT + 99 others); Wed, 24 Oct 2018 00:29:58 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:34780 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725266AbeJXE36 (ORCPT ); Wed, 24 Oct 2018 00:29:58 -0400 Received: by mail-yw1-f66.google.com with SMTP id v199-v6so1098445ywg.1 for ; Tue, 23 Oct 2018 13:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=4MCSMXG0/Rs9wIHCX+w1Qy6QE/zsrASHTckZZZ6XpL8=; b=B1arXYMO15yLSTL7xIOmMxOad8mI/VlMGmQ2ZM9VD+2Jjkun70oiCvt9sUOrS4reie bBLUljDLzhICa7Q9HSXW6mc8P6nlFdc1LsVPjm1aa722iQprKpiqgzqnQzGGdH7g0jW6 5LYu+K0Y1l24ICXZt+oZd4BevrIwzuJJqh+Hg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=4MCSMXG0/Rs9wIHCX+w1Qy6QE/zsrASHTckZZZ6XpL8=; b=Vj2hz6U6HghxGNIV8zgwUVcvsr9cFaFthvImNIsdXwDvu16V9tnhrDmalTAHa4hnMY pxlmSFxzbyT+ISdeuhJPNP1B4huDUWzXHyKKIB8jQiWfRfdz9jD+TctBBLRkcGKgCPCK YpgCbP8Nt4Jr9WiqFPVH/OKxBrf7FbteJt9s8G6LjJlQQv/Ytfcm7An0C8gJL0fmOMTo SODU2e5v5kCRasL3/RyK3IO//2d82FXxUrcEeYNQ6cspGhxiGu8wDPY2PprZRQ9v/ntD iULSU8TkY09kThGcGiO7HkQU9X95+V8wkmMw9MKBempsB6QULKBqmrkUYaw+yGLh9kYI z7kg== X-Gm-Message-State: ABuFfohmc8oBDZjU/jQZwHfTN6+FUoBqljDL86FvuOBfG3H7ASwir1Mv dJO0QN4u2OfRBwjglJuTUkdSYZPpnXk= X-Received: by 2002:a81:f104:: with SMTP id h4-v6mr30822213ywm.20.1540325102945; Tue, 23 Oct 2018 13:05:02 -0700 (PDT) Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com. [209.85.219.171]) by smtp.gmail.com with ESMTPSA id o131-v6sm528237ywb.107.2018.10.23.13.05.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 13:05:01 -0700 (PDT) Received: by mail-yb1-f171.google.com with SMTP id g75-v6so1106302yba.10 for ; Tue, 23 Oct 2018 13:05:01 -0700 (PDT) X-Received: by 2002:a25:ac8e:: with SMTP id x14-v6mr9847950ybi.141.1540325100703; Tue, 23 Oct 2018 13:05:00 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:3990:0:0:0:0:0 with HTTP; Tue, 23 Oct 2018 13:04:59 -0700 (PDT) In-Reply-To: <15247f54-53f3-83d4-6706-e9264b90ca7a@yandex-team.ru> References: <1540229092-25207-1-git-send-email-arunks@codeaurora.org> <15247f54-53f3-83d4-6706-e9264b90ca7a@yandex-team.ru> From: Kees Cook Date: Tue, 23 Oct 2018 13:04:59 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mm: convert totalram_pages, totalhigh_pages and managed_pages to atomic. To: Konstantin Khlebnikov Cc: Joe Perches , Arun KS , LKML , linux-mm , Minchan Kim , Michal Hocko , Arun Sudhilal , Greg Kroah-Hartman , Andrew Morton Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 22, 2018 at 10:11 PM, Konstantin Khlebnikov wrote: > On 23.10.2018 7:15, Joe Perches wrote:> On Mon, 2018-10-22 at 22:53 +0530, > Arun KS wrote: >>> Remove managed_page_count_lock spinlock and instead use atomic >>> variables. >> >> Perhaps better to define and use macros for the accesses >> instead of specific uses of atomic_long_ >> >> Something like: >> >> #define totalram_pages() (unsigned >> long)atomic_long_read(&_totalram_pages) > > or proper static inline > this code isn't so low level for breaking include dependencies with macro BTW, I noticed a few places in the patch that did multiple evaluations of totalram_pages. It might be worth fixing those prior to doing the conversion, too. e.g.: if (totalram_pages > something) foobar(totalram_pages); <- value may have changed here should, instead, be: var = totalram_pages; <- get stable view of the value if (var > something) foobar(var); -Kees > [dropped bloated cc - my server rejects this mess] Thank you -- I was struggling to figure out the best way to reply to this. :) -Kees -- Kees Cook