From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-175.mta1.migadu.com (out-175.mta1.migadu.com [95.215.58.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 691CD525A for ; Tue, 23 Jan 2024 02:23:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705976604; cv=none; b=dzj3BvzNDNaIeU1FocyaFX04tFMHjMfGVU6NtFVgwaztNAKxeWASPFcODGOSdHjtkN2l+OOLeWFjGAY40RyRzVl/Ek5Np1Prre8zy5lj01df9TNT7jp+K/Vm8mXGvkz6ApUBiJdYK7UJPAfR1E8BzEyhNeoL2ENKs6OHQDShSmM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705976604; c=relaxed/simple; bh=O3GX1nlYcs0zSCd7nC1/5Xu01YhkOecXq9lefI4hJyo=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=tEW5YbkBnmo6wnjLRSMQ9ODOrAAv597VRB/8yeJ4JyZz5dJoELZ3OJ3exem/UZfU/9zA6hrgpEYtdnywnK6R1rWBtQCTktZtxvKhkONHlWi4MHuUFTvLvVJQ1Gei03DvO+jFpoksgJXZvkJpgLh1avhBXKh/bV82WS+8B5pzPZc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=GRBybsmf; arc=none smtp.client-ip=95.215.58.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="GRBybsmf" Message-ID: <2a1d6a9b-f486-44c8-6d1d-e6bab4dc3ced@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1705976600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fy9JI9s5CgHc9vU6scmFm3fgR9U6bOckIRvEe1L/hPs=; b=GRBybsmfuXKfd/mLRS+wIrZFlZhpe5WRZDKnbLkyNE08NsBjmFBbwFh81efoeyV1P1WVoU 6v4Wtv83tk6Q9yBSGWM4QQd0AFwYf6FQL8TQguA0eKL0vRpmzSPfJrxMlNqbBgsid1RAfm rVJdEY1UzcYcbLOjMvO++uDDfQGi4pk= Date: Tue, 23 Jan 2024 10:23:14 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] mm/mmap: introduce vma_range_init() Content-Language: en-US To: "Liam R. Howlett" , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240111021526.3461825-1-yajun.deng@linux.dev> <20240122220031.pwiravglee7o7k34@revolver> <20240122154031.b710f834b14d9027176f439a@linux-foundation.org> <20240123001830.glqdmrv2qc56zfpc@revolver> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yajun Deng In-Reply-To: <20240123001830.glqdmrv2qc56zfpc@revolver> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2024/1/23 08:18, Liam R. Howlett wrote: > * Andrew Morton [240122 18:40]: >> On Mon, 22 Jan 2024 17:00:31 -0500 "Liam R. Howlett" wrote: >> >>> * Yajun Deng [240110 21:15]: >>>> There is a lot of code needs to set the range of vma, introduce >>>> vma_range_init() to initialize the range of vma. >>>> >>>> Signed-off-by: Yajun Deng >>>> --- >>>> include/linux/mm.h | 9 +++++++++ >>>> mm/mmap.c | 29 +++++++---------------------- >>>> 2 files changed, 16 insertions(+), 22 deletions(-) >>> This isn't a whole lot of code, are there others? We're losing code >>> clarity in favour of saving 6 lines? >>> >> Oh. I thought it was a nice cleanup which made things more clear. > I'm not totally against it; that's why I suggested the changes below. I > think a name change would go a long way for clarity. It's not as much as > I though it would be though. > >>>> diff --git a/include/linux/mm.h b/include/linux/mm.h >>>> index f5a97dec5169..abb4534be3cc 100644 >>>> --- a/include/linux/mm.h >>>> +++ b/include/linux/mm.h >>>> @@ -3516,6 +3516,15 @@ static inline bool range_in_vma(struct vm_area_struct *vma, >>>> return (vma && vma->vm_start <= start && end <= vma->vm_end); >>>> } >>>> >>>> +static inline void vma_range_init(struct vm_area_struct *vma, >>> Any reason this can't be in mm/internal.h ? >> That would be good. > One other thing, do we trust this to be inlined correctly by the > compiler or should this be __always_inline? I'd expect it to be okay as > it is, but I've been proven wrong in a perf trace before.. > Okay, I would take __always_inline and put it in mm/internal.h in v2. >>> vma_range_set(), vma_set_range(), or just vma_range() might be a better >>> name? My thinking is that some of these are actually modifying the vma >>> and not just initializing it, right? >> I'd vote for vma_set_range(). >> > Using vma_set_range() leaves vma_range() or vma_size(), which could be > added for the calculations of vma->vm_end - vma->vm_start. Davidlohr > suggested such a beast a few years ago, but that one would need to live > in the include/linux/mm.h as it occurs a lot more. > > $ git grep "vma->vm_end - vma->vm_start" | wc -l > 198 > > .. for just those named vma. >