Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp1147867ima; Fri, 1 Feb 2019 17:32:51 -0800 (PST) X-Google-Smtp-Source: ALg8bN6xT27FFvCHUQZZbouUM08cCQj3BmZuhNavRlvGc1YjEQHkIP+e/yI+PZl/ZjLlT9tsIkXi X-Received: by 2002:a17:902:930b:: with SMTP id bc11mr43032117plb.17.1549071171820; Fri, 01 Feb 2019 17:32:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549071171; cv=none; d=google.com; s=arc-20160816; b=vte328LyA7Z1FBusNwWVzGOuotLRe3iO9HizUlcqvBxuqCRebL8TGNkLUKMa7R0fEq 9H2rl/7z3f93dJs1N/3XGT8Ck90OP0250ZhFAybuV5bTDi4h3tt/kTgYLCY+2hC/lyp5 3Wc/VlLjMv2BkrIeijsZOzkCuZaxvbIceqBFKdhrLOZiZNPOtsqp7/feId+8lQa8L0WQ Zk0tco7V992EtHT2TQXdKN+OkJG5gxuQxJyYcnD25nMxBY1mvUXU9SCc/NsZ6sNes1oV 3wH53pFD6hAIrUp6NGuHWh5i8NvruR+9Z4U/goD1DdtC7UUFTuAJkZDsnwsCAajK40Zr 0WAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=fhuuF/1TJblxzF7+tEwXL1uL/HfX1tfgwA49XT+HUdg=; b=tD8zL/mbsT5PF7trGS+8gDuqWNLpFpXIAxwJhvXcZndxVS76Mm3uWvW2QaM4D7nUxM 3C8T7Q+w0Wf76fypkCdnRadWd/LA11tL/qcLHrs/2nYTgwc2iWum7LNUoXCrcLkQI5fF jxbYgw2TFNsK7+Zh+cJJW6F3OMi5gKGB+6rOtuLXADts+baHo0bzZ8Xpr9sYjWQznI19 rfpZaCPyYhI4LJ8eT2EKLfUgwxiW4xUBYUT1JrliOu/zKiIJIRrKfIXjQ/42KwaCQwfI PLmRP43SURJtQz3GpHBy1qbnDIR+wZhf4DkzIHo9oRmQ8XKtAIu+Qah7tlJAmoTBCvTu 1JhQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cd16si10140934plb.47.2019.02.01.17.32.00; Fri, 01 Feb 2019 17:32:51 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727202AbfBBBNr (ORCPT + 99 others); Fri, 1 Feb 2019 20:13:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37280 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726217AbfBBBNr (ORCPT ); Fri, 1 Feb 2019 20:13:47 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 521F57F771; Sat, 2 Feb 2019 01:13:47 +0000 (UTC) Received: from sky.random (ovpn-121-14.rdu2.redhat.com [10.10.121.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2486460C62; Sat, 2 Feb 2019 01:13:41 +0000 (UTC) Date: Fri, 1 Feb 2019 20:13:40 -0500 From: Andrea Arcangeli To: jglisse@redhat.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Peter Xu , Andrew Morton , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , kvm@vger.kernel.org Subject: Re: [RFC PATCH 2/4] mm/mmu_notifier: use unsigned for event field in range struct Message-ID: <20190202011340.GD12463@redhat.com> References: <20190131183706.20980-1-jglisse@redhat.com> <20190131183706.20980-3-jglisse@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190131183706.20980-3-jglisse@redhat.com> User-Agent: Mutt/1.11.2 (2019-01-07) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 02 Feb 2019 01:13:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 31, 2019 at 01:37:04PM -0500, Jerome Glisse wrote: > From: Jérôme Glisse > > Use unsigned for event field in range struct so that we can also set > flags with the event. This patch change the field and introduce the > helper. > > Signed-off-by: Jérôme Glisse > Cc: Andrea Arcangeli > Cc: Peter Xu > Cc: Andrew Morton > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: kvm@vger.kernel.org > --- > include/linux/mmu_notifier.h | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h > index be873c431886..d7a35975c2bd 100644 > --- a/include/linux/mmu_notifier.h > +++ b/include/linux/mmu_notifier.h > @@ -6,6 +6,7 @@ > #include > #include > #include > +#include > > struct mmu_notifier; > struct mmu_notifier_ops; > @@ -38,8 +39,11 @@ enum mmu_notifier_event { > MMU_NOTIFY_PROTECTION_VMA, > MMU_NOTIFY_PROTECTION_PAGE, > MMU_NOTIFY_SOFT_DIRTY, > + MMU_NOTIFY_EVENT_MAX > }; > > +#define MMU_NOTIFIER_EVENT_BITS order_base_2(MMU_NOTIFY_EVENT_MAX) > + > #ifdef CONFIG_MMU_NOTIFIER > > /* > @@ -60,7 +64,7 @@ struct mmu_notifier_range { > struct mm_struct *mm; > unsigned long start; > unsigned long end; > - enum mmu_notifier_event event; > + unsigned event; > bool blockable; > }; This is only allocated in the stack, so saving RAM by mixing bitfields with enum in the same 4 bytes to save 4 bytes isn't of maximum priority. A possibly cleaner way to save those 4 bytes without mixing enum with bitfields by hand, is to add a "unsigned short flags" which will make "event/flags/blockable" fit in the same 8 bytes (bool only needs 1 byte) as before the patch (the first bitfield can start from 0 then). Yet another way is to drop blockable and convert it to a flag in "unsigned int flags".