Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp47531lqp; Mon, 10 Jun 2024 17:56:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQkHuhrym9HacCYddg+A/bTZPcNTQdf0Kk204ojhu+r+wg3h0SZoAheEfUajJJzPjH+mai/DSxRpxSv+71QlJsIEAwB2HomylMkvnhXw== X-Google-Smtp-Source: AGHT+IG2VSBnWUaLz0ZZ5k5FnpcOqKAWazQdFLKYT7IusxzLhyn7An47G9zVOT6V8NjCJKqKfNSN X-Received: by 2002:a17:906:29d5:b0:a6f:1b47:9fa3 with SMTP id a640c23a62f3a-a6f1b47a09emr296309466b.41.1718067409496; Mon, 10 Jun 2024 17:56:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718067409; cv=pass; d=google.com; s=arc-20160816; b=B8usXCJRnvQLdW4o8C+ohFiu4KdGULTPvFL7i4w55E1hmwKVaJ9ge6kWOespRoYR6R QPsKaVwykt/abQcC3zxvL3pIpKbZIg0+lJGKVm0zWNsV8kD42HmMeyZV3woJi8K4jWNk 56EaPUA4ukyLSYj/F3JOFlcxHEshlBaWV+fRyzYwuYvGfNfPXKUn2D5f3dlotf6t7vCM dP/R+3SmDDMQTSz6gAfdaaxuTMgi7EUhDh3r4HrO39t9HbCKNhYe0LPELRT/CkLHgvtB nuDyU0UoFXj/+FxUVQ4PBtTDEyZGhGemley9zuasZPl8Z/M6+2UNnsU0ckY5OFh5QmNX ASIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=JsnMWiRsFgyQvUVQ9cK3PkkXIy3mFEoHC4cpzhwBfS0=; fh=Q1zGR2kddN5M862BLNoXDti4UwIU+GvUoleaf1YTUCA=; b=AEnumqkAizoDiJ2BsfX1pUJ3tPI3+8s07HixLxMcZxx1EetGOJBvgW+QYEvH4OG/fj 4he6eu2Gcncsk4SGCCGlmafUrcPGLVTeMGTfAvrHZsDsMlhz3IijZHPGFg3zoO6JUY+l mGhTNN1tsZpPttqcLAZYsVEGhdD5L/3GrmU8jRuaZmgdImNgrqpMqMaw7enilLrFRgDm CYuShj3F6qP/5N9Urs0hWLxG86ymp9Z/ZXzwh2ddHc0Cnt7aIh3a3eSQ+RsOwR8ufO2W 836hsB5PjBQexD9neT4F9HtBK9n/f//12/XrMOJLhHq6bb2rf7K1w3oAODacVqb2ffR1 GxZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gS2WFbgv; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-209139-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209139-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6efe06b0f7si301601566b.1024.2024.06.10.17.56.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 17:56:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209139-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gS2WFbgv; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-209139-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209139-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0BA491F22BA1 for ; Tue, 11 Jun 2024 00:56:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5CE8163CB; Tue, 11 Jun 2024 00:56:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gS2WFbgv" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D55434C81 for ; Tue, 11 Jun 2024 00:56:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718067401; cv=none; b=F4CGS1sIR+xLO5K99/5tjzJKNwl+GBH4j2kLufmzVEudTmEVecXjD9dm9jp4GOwX2O4LrGo6qw9mm1RxSlg1M9ZAeNAfw2xwgfukWUVp4qa5W1fZ7EMc4aRIiPC9fNkBBoX65bCR4phuyESfVEt1CCajEgjFw6MPWVXh8YkGMOo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718067401; c=relaxed/simple; bh=pWf61BOW6LDJhVR+p7Jr3ddwtK37jvFhbQjHtR1senQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HPABuDF3EoSA5lFFcB0dko94RUcxxQQ7/oBiymbLT4YBogTWIipGP2OuyFq7bAqEhF3rZ74jm49/Z1Eh8TfZw7ajwOlRLOF5u4fXiZZoj0LAjlte0xm07c3MvrW4J1xW6RGSEfP4VW0X+RXCb4zh9i871pyCUJt3vNh4JbqE7Hk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gS2WFbgv; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a6f1c4800easo194048366b.3 for ; Mon, 10 Jun 2024 17:56:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718067398; x=1718672198; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=JsnMWiRsFgyQvUVQ9cK3PkkXIy3mFEoHC4cpzhwBfS0=; b=gS2WFbgvNuFMST0ySHSNykEdjMWiaMnYhEr0nmdeYt77xXxrq9CFUWMHxnFoCLn00H nsMy+9JwH4YOXY45x3s+KFK+CPKMHNFiXxfeuJ8a0+BzhSm0xTqijEn7bZvm7DF/ca43 1V17Qkz2XXv2mAzOKIjHHJnPy99IQKQDu9WLcEq63fUG8cp5CScPWezjD9R0x1Ju1JNu dpievKpoHp8ttgIqTw2gzo73/DUaOIuMBJTwOrc2i4UYHCYALMn5xuwHmATOv/k+y+pD MY5htcIfk/PyQIi8Ep2OI3LhiS1m2x6+oWMRwseOsRII2JJ9i1cAS4A9sxmjMpiRtEuU xMoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718067398; x=1718672198; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JsnMWiRsFgyQvUVQ9cK3PkkXIy3mFEoHC4cpzhwBfS0=; b=PMEWGEAJvsq5JXZYIA0fzMhy4qgAtDkiURl/kQ+6xD82Dv0xKZxKsaRfn6sXSCUUyV i0TUk4whqjyXG5CH0QiOL9wp8G4sd2c8lj7upN1H8VuBaocbh89AUGoXANKBLucjutzY sASpL9KgVNaOQNx5z6z+DtOTCA+PI9y67sF8OcExNrTaGUWpM0SsWIagA/5hvuIOlH6U ICskt+ejtLRcv48hEPRZIUxzvEmZbq4x6s0pylJH5f+Eio5E06ero+siYtQPKhyyql0W VazyiT3V7KGwUnlzqk11HvXHZ6HIafXXoXNK+lDYtDWtwKbThD8HC3lUxgkps4LkstjD H+dg== X-Forwarded-Encrypted: i=1; AJvYcCWKX4Gs9OHohvWVW8noDT0vwLM+tRLM1z1xKvyCT4pLBokQzHpUH8KEG60wyIAvAts+lLc1kJq7QrphimkCaxcXEQwcawh5xM8CjVxq X-Gm-Message-State: AOJu0YyHqYti5sb+UQNr6ZJKlKcTVTBCveahcLWP9/cO+rGMuc9kpEsb OmOjuWHxwKmjqgGFSo52Of6Kss5ZiHb3vyRf3zhyrFLAwhlidmy3EE7wWy9/ X-Received: by 2002:a17:906:b4d:b0:a6f:238:85c8 with SMTP id a640c23a62f3a-a6f02389247mr472356466b.71.1718067397868; Mon, 10 Jun 2024 17:56:37 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f1226c190sm309544166b.93.2024.06.10.17.56.37 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jun 2024 17:56:37 -0700 (PDT) Date: Tue, 11 Jun 2024 00:56:36 +0000 From: Wei Yang To: David Hildenbrand Cc: Oscar Salvador , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Wei Yang Subject: Re: [PATCH v1 2/2] mm/highmem: make nr_free_highpages() return "unsigned long" Message-ID: <20240611005636.g6525rkqpos43yds@master> Reply-To: Wei Yang References: <20240607083711.62833-1-david@redhat.com> <20240607083711.62833-3-david@redhat.com> <99073d55-5b18-4ed2-b860-8c09e056f585@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <99073d55-5b18-4ed2-b860-8c09e056f585@redhat.com> User-Agent: NeoMutt/20170113 (1.7.2) On Mon, Jun 10, 2024 at 10:22:49AM +0200, David Hildenbrand wrote: >On 10.06.24 05:40, Oscar Salvador wrote: >> On Fri, Jun 07, 2024 at 10:37:11AM +0200, David Hildenbrand wrote: >> > It looks rather weird that totalhigh_pages() returns an >> > "unsigned long" but nr_free_highpages() returns an "unsigned int". >> > >> > Let's return an "unsigned long" from nr_free_highpages() to be >> > consistent. >> > >> > While at it, use a plain "0" instead of a "0UL" in the !CONFIG_HIGHMEM >> > totalhigh_pages() implementation, to make these look alike as well. >> > >> > Signed-off-by: David Hildenbrand >> ... >> > -static inline unsigned int nr_free_highpages(void) { return 0; } >> > -static inline unsigned long totalhigh_pages(void) { return 0UL; } >> > +static inline unsigned long nr_free_highpages(void) { return 0; } >> > +static inline unsigned long totalhigh_pages(void) { return 0; } >> >> Although I doubt it has any consequences, I would just leave them both with UL, >> so the return type is consistent with what we are returning. > >These suffixes are only required when using constants that would not fit >into the native (int) type, or converting from that native (int) type to >something else automatically by the compiler would mess things up (for example, >undesired sign extension). For 0 that is certainly impossible :) > > >That's also the reason why in include/linux we now have: > >t14s: ~/git/linux/include/linux $ git grep "return 0UL;" >skbuff.h: return 0UL; >uaccess.h:static inline unsigned long user_access_save(void) { return 0UL; } >t14s: ~/git/linux/include/linux $ git grep "0UL;" >bitmap.h: *dst = ~0UL; >dax.h: return ~0UL; >mtd/map.h: r.x[i] = ~0UL; >netfilter.h: return ((ul1[0] ^ ul2[0]) | (ul1[1] ^ ul2[1])) == 0UL; >skbuff.h: return 0UL; >uaccess.h:static inline unsigned long user_access_save(void) { return 0UL; } > > >... compared to a long list if "unsigned long" functions that simply "return 0;" > Seems this is the current status. Then my question is do we have a guide line for this? Or 0 is the special case? Sounds positive value has no sign extension problem. If we need to return 1, we suppose to use 1 or 1UL? I found myself confused. I grepped "return 1" and do find some cases without UL: backing-dev.h: wb_stat_error() return 1 for unsigned long. pgtable.h: pte_batch_hint() return 1 for unsigned int. So the guide line is for positive value, it is not necessary to use UL? > >So I prefer to just drop it. > >Thanks! > >-- >Cheers, > >David / dhildenb -- Wei Yang Help you, Help me