From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 933DBC3DA7F for ; Mon, 5 Aug 2024 08:19:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D19656B007B; Mon, 5 Aug 2024 04:19:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC9B36B0082; Mon, 5 Aug 2024 04:19:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B91E16B0085; Mon, 5 Aug 2024 04:19:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9B2796B007B for ; Mon, 5 Aug 2024 04:19:25 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 40502C0137 for ; Mon, 5 Aug 2024 08:19:25 +0000 (UTC) X-FDA: 82417492290.23.C49E51C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 356D11C0012 for ; Mon, 5 Aug 2024 08:19:23 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GDLtjS1z; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of jasowang@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=jasowang@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722845956; a=rsa-sha256; cv=none; b=eiub+3hoiT8MyvC5GnGC/zh33PEP2HSDwS8yu1J/bMibgCRQL23PnaSI/5b+FWzIhJQGqd 8LDv0173QxPvsyJcVGybZaNwPPNstAMzDs83SDFURso/Q2/blVH9sHzumgzKvuzLetyqgf UFBrBNAGf44q/zCkfKxrV61Ln/GtVDg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GDLtjS1z; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of jasowang@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=jasowang@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722845956; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nPeV1gsloDiYR3vfei+0mC3bzo4TVj+mZW32CL0XRQs=; b=zLztXlniF7dV4PNdGZZamyTYa+VGR1UIoIP6R3Ya1LmVBXq9EaH5ThrKu5yKVLaaa1I04f NsVamtB9Pl/CfKiOYdpi3AWFR0oFN+rcizXK09zbG/j57s1l5zqXn+rH0UNyCMlu2fIhCE f18DjsZZT2kYvYF9fFzTRYJ1Ir0HixU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722845962; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nPeV1gsloDiYR3vfei+0mC3bzo4TVj+mZW32CL0XRQs=; b=GDLtjS1zAwmU5pQpzkjHcYUN2fbf7UXw/kQ53QAjEuedXUO0Jl9E5TD6qZkZOb9R8VM4/h siYx2B8swusSR5UgTiIGrEzsAXs2/+DDznfUFQf7DReEtuZqE9uPzfyaaKCuFyrG2kHC9p 023KZWuSm66IS0dyBBVPZB4NRYAktk4= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-68-tffFnOd0PzqZ-dQyGtNzyA-1; Mon, 05 Aug 2024 04:19:20 -0400 X-MC-Unique: tffFnOd0PzqZ-dQyGtNzyA-1 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-7106ed795deso1890207b3a.1 for ; Mon, 05 Aug 2024 01:19:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722845959; x=1723450759; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nPeV1gsloDiYR3vfei+0mC3bzo4TVj+mZW32CL0XRQs=; b=ZyYySX1DmvpWIGeTtYb73372qcFqpzU46Pw1d4LwEzKzGNQs4Uk1wxmyelURgW15R5 agl47S8osMt9BKA+xAgLyPe70Yba3f6yEgVOstW88Y+mIa/x7Xmz2TMg5+9i+Jf+rSbQ Z26cV4ALKMxspQA3Eyz+UJYhMlGjYS79KEScOG/9lfDBdzJ2jgrlqMlqKcdw80RpRVG9 6JELZ2UBBowC9m1phr9p75WdP4EUjO925yc5jCgjOofFVMOT0tJ8vdNu7ACYW+GP/G+C nX1t54yScUWXQPLsTw83mgZwOrHOhKQh5hDB00NJ7TI10x3yE4e/UaonVZLGn86lPyz5 8jMg== X-Forwarded-Encrypted: i=1; AJvYcCWjl2xipmJKSlvSy5nqtpEQ55Oc0C+CQtJPAfyCEUbCxJGamVW6irQQqzi2jCuZ50Pk5lQIw8ftU3A216A1FRJcNzY= X-Gm-Message-State: AOJu0YwuYfnzSL5VaQqWJVMu6YNcvSPf4YYH2PhKtejhq8t8ESx9Omrq bMvEyF/cS+ZJ6gff8n4NPuCYcr2NB5N5IvDyYuoWY06VHEUKcRvKiaw91K3MV3D4tQjq2IU3drN 6X6GCiS48udc1jOiRUlulattiVfAD14Th1T7BUFEOls8JwEJ4nRYq2gpjjdrMTIEMNvssxUcEWh Njda2C2UmAM/V4a9Ig3SswoT0= X-Received: by 2002:a05:6a20:1596:b0:1c0:e540:7336 with SMTP id adf61e73a8af0-1c69953c6d7mr11417876637.6.1722845959142; Mon, 05 Aug 2024 01:19:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCgBhtG+yOFYmHSFTJlmGmVO1awlwisnl4+298Q5sNjvlwKIWZTqtBD1h3Jrw4qpJK8bHVieJFMVTQ/lthEdo= X-Received: by 2002:a05:6a20:1596:b0:1c0:e540:7336 with SMTP id adf61e73a8af0-1c69953c6d7mr11417853637.6.1722845958564; Mon, 05 Aug 2024 01:19:18 -0700 (PDT) MIME-Version: 1.0 References: <20240731000155.109583-1-21cnbao@gmail.com> <20240731000155.109583-2-21cnbao@gmail.com> In-Reply-To: From: Jason Wang Date: Mon, 5 Aug 2024 16:19:07 +0800 Message-ID: Subject: Re: [PATCH RFT v2 1/4] vpda: try to fix the potential crash due to misusing __GFP_NOFAIL To: Barry Song <21cnbao@gmail.com> Cc: Tetsuo Handa , akpm@linux-foundation.org, linux-mm@kvack.org, 42.hyeyoo@gmail.com, cl@linux.com, hailong.liu@oppo.com, hch@infradead.org, iamjoonsoo.kim@lge.com, lstoakes@gmail.com, mhocko@suse.com, penberg@kernel.org, rientjes@google.com, roman.gushchin@linux.dev, torvalds@linux-foundation.org, urezki@gmail.com, v-songbaohua@oppo.com, vbabka@suse.cz, virtualization@lists.linux.dev, "Michael S. Tsirkin" , Xuan Zhuo , =?UTF-8?Q?Eugenio_P=C3=A9rez?= , Maxime Coquelin , Yongji Xie X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Queue-Id: 356D11C0012 X-Rspamd-Server: rspam01 X-Stat-Signature: oc553bwxmdp17we4ryh15neazqsf3w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HS51Bh/CilF16G73xCtoNvKdJ8s3BbAV7Ep/zTDY+BVv7E3ysCjf6LwclhoRqYhJj1X/jSthRN/8dnhuVqDEubPaoHIx/mdR71I0sEV0zCZoOmCNGtHgaIil6mZVzmTh2Z6SvQabS448noBeGS5cMhcpBJM1fuaLHrLw85NOtdsyrk98pj0nF8od8lL2e6tvpxvldIdwVox59LM00qKdW6qGo3ZcHdgbh/uqT/dAFPqSAaOYJPJck8ai1fQGRoISntBWgaKoP52CjRAiDYHR3sxV5XBuaPesBCvYCIcz0CwGKNOVysF5rLKRtG++CjC2RbWHbNdqitMWy5HM52YnaIRXsyf24YgecH0NbJrYb/qeTmUNc+6oJ8wdVpHyT71PkVpAuC+9SqNU+rkVa+5bRrHgSEH19Ib4QVk1L9mItoLTJLnl//d5DwTxg5gOivKIAEI9u9CzXIGffNLWA/Ml9BI/j1xZPDCnh7pT9Wcs8E8eCkcANrUK3Ukx01OktzdHVffa1H5lXEmocmT8ea6CsWJe8xbDI1iiyZI7pMZIbajZk/6R4b X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, Aug 5, 2024 at 9:32=E2=80=AFAM Barry Song <21cnbao@gmail.com> wrote= : > > On Thu, Aug 1, 2024 at 2:37=E2=80=AFPM Jason Wang w= rote: > > > > On Wed, Jul 31, 2024 at 6:21=E2=80=AFPM Tetsuo Handa > > wrote: > > > > > > On 2024/07/31 14:05, Barry Song wrote: > > > > Jason, > > > > Thank you very much. Also, Tetsuo reminded me that kmalloc_array() = might be > > > > problematic if the count is too large: > > > > pages =3D kmalloc_array(count, sizeof(*pages), GFP_KERNEL | __GFP_= NOFAIL); > > > > > > If "count" is guaranteed to be count <=3D 16, this might be tolerable= . > > > > It's not unfortunately, the maximum bounce buffer size is: > > > > #define VDUSE_MAX_BOUNCE_SIZE (1024 * 1024 * 1024) > > > > > > > > Consider a situation where current thread was chosen as an global OOM= victim. > > > Trying to allocate "count" pages using > > > > > > for (i =3D 0; i < count; i++) > > > pages[i] =3D alloc_page(GFP_KERNEL | __GFP_NOFAIL); > > > > > > is not good. > > > > Right, I wonder if we need to add a shrink to reclaim the pages that > > belong to VDUSE bounce pages. > > > > > > > > > > > > > You might want to consider using vmalloc_array() or kvmalloc_array(= ) instead > > > > when you send a new version. > > > > > > There is a limitation at https://elixir.bootlin.com/linux/v6.11-rc1/s= ource/mm/page_alloc.c#L3033 > > > that you must satisfy count <=3D PAGE_SIZE * 2 / sizeof(*pages) if yo= u use __GFP_NOFAIL. > > > > > > But as already explained above, allocating 1024 pages (assuming PAGE_= SIZE is 4096 and > > > pointer size is 8) when current thread was chosen as an OOM victim is= not recommended. > > > You should implement proper error handling instead of using __GFP_NOF= AIL if count can > > > become large. > > > > I think I need to consider a way to avoid __GFP_NOFAIL. A easy way is > > not to free the kernel bounce pages, then we don't need to allocate > > them again. > > Let's try to do a fix for this patch as we are waiting for your official = patch > in mm. Will post this soon. One note here is that I don't have handy usersapce that uses userspace bounce pages (neither libvduse nor DPDK did that). I hope YongJi can review and give a test on that. Thanks > > I guess, further optimization can be a separate patch later in the driver= 's > tree :-) > > > > > Thanks > > > > > > > > > > >