From patchwork Mon Nov 30 10:09:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Wiedmann X-Patchwork-Id: 335066 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68DE4C64E90 for ; Mon, 30 Nov 2020 10:11:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE0BD206C0 for ; Mon, 30 Nov 2020 10:11:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="hJbFBvbh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729120AbgK3KK4 (ORCPT ); Mon, 30 Nov 2020 05:10:56 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:29012 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729065AbgK3KKz (ORCPT ); Mon, 30 Nov 2020 05:10:55 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AUA4Drq185690; Mon, 30 Nov 2020 05:10:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=Cvo6N9HgZXq8P8WB8cCNgaGAGjQzUeJSiLL6K3eLgu4=; b=hJbFBvbhS1GCEI+6XSZyVWtaqAYkAJlVebMSRsaB1njX6LUbnXKjZpz1gRLmRcBbPNsY 4i1i0ptnAhFfzlA8utDcZRLp5Tu3v3fV2J3q9RINw/XFpyHIbZ5g8DzVIgz2q5kaV49v cqSoJ0eCWHrGGFRb2d9Z6GmkYOLn6Cwu1nicD/NoP17WRhOf2n7eBsQIZgzhsLCOYcOx mpjZ3UhCDcVWKMweqO2OVOlBxgI58rQu9lGD1GN54UazaBG5P3u3XWilygiPtX4rKetX p/vPpHy/PEKJMDkR40XnfW6Weto084vRzieJLpSAkGCJXOgef86CFvnXPFVeYgn1dW2S 1Q== Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 354x1as31a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2020 05:10:00 -0500 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0AUA8lLE018399; Mon, 30 Nov 2020 10:09:57 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma03fra.de.ibm.com with ESMTP id 353e682tt7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2020 10:09:56 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0AUA9sZx9372160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Nov 2020 10:09:54 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F33FD11C04A; Mon, 30 Nov 2020 10:09:53 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ADE0011C050; Mon, 30 Nov 2020 10:09:53 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 30 Nov 2020 10:09:53 +0000 (GMT) From: Julian Wiedmann To: David Miller , Jakub Kicinski Cc: linux-netdev , linux-s390 , Heiko Carstens , Karsten Graul , Julian Wiedmann , Sebastian Andrzej Siewior Subject: [PATCH net-next 1/6] s390/ctcm: Avoid temporary allocation of struct th_header and th_sweep. Date: Mon, 30 Nov 2020 11:09:45 +0100 Message-Id: <20201130100950.42051-2-jwi@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201130100950.42051-1-jwi@linux.ibm.com> References: <20201130100950.42051-1-jwi@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-30_02:2020-11-30,2020-11-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 lowpriorityscore=0 suspectscore=2 bulkscore=0 adultscore=0 phishscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011300063 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Sebastian Andrzej Siewior The size of struct th_header is 8 byte and the size of struct th_sweep is 16 byte. The memory for is allocated, initialized, used and deallocated a few lines later. It is more efficient to avoid the allocation/free dance and assign the values directly to skb's data part instead of using memcpy() for it. Avoid an allocation of struct th_sweep/th_header and use the resulting skb pointer instead. Signed-off-by: Sebastian Andrzej Siewior [jwi: use skb_put_zero(), instead of skb_put() + memset to 0] Signed-off-by: Julian Wiedmann --- drivers/s390/net/ctcm_fsms.c | 15 ++++----------- drivers/s390/net/ctcm_main.c | 31 ++++--------------------------- drivers/s390/net/ctcm_mpc.c | 16 +--------------- 3 files changed, 9 insertions(+), 53 deletions(-) diff --git a/drivers/s390/net/ctcm_fsms.c b/drivers/s390/net/ctcm_fsms.c index 661d2a49bce9..b341075397d9 100644 --- a/drivers/s390/net/ctcm_fsms.c +++ b/drivers/s390/net/ctcm_fsms.c @@ -1303,12 +1303,10 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) /* p_header points to the last one we handled */ if (p_header) p_header->pdu_flag |= PDU_LAST; /*Say it's the last one*/ - header = kzalloc(TH_HEADER_LENGTH, gfp_type()); - if (!header) { - spin_unlock(&ch->collect_lock); - fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev); - goto done; - } + + header = skb_push(ch->trans_skb, TH_HEADER_LENGTH); + memset(header, 0, TH_HEADER_LENGTH); + header->th_ch_flag = TH_HAS_PDU; /* Normal data */ ch->th_seq_num++; header->th_seq_num = ch->th_seq_num; @@ -1316,11 +1314,6 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) CTCM_PR_DBGDATA("%s: ToVTAM_th_seq= %08x\n" , __func__, ch->th_seq_num); - memcpy(skb_push(ch->trans_skb, TH_HEADER_LENGTH), header, - TH_HEADER_LENGTH); /* put the TH on the packet */ - - kfree(header); - CTCM_PR_DBGDATA("%s: trans_skb len:%04x \n", __func__, ch->trans_skb->len); CTCM_PR_DBGDATA("%s: up-to-50 bytes of trans_skb " diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c index d06809eac16d..9e28c63415ed 100644 --- a/drivers/s390/net/ctcm_main.c +++ b/drivers/s390/net/ctcm_main.c @@ -623,25 +623,10 @@ static void ctcmpc_send_sweep_req(struct channel *rch) goto nomem; } - header = kmalloc(TH_SWEEP_LENGTH, gfp_type()); - - if (!header) { - dev_kfree_skb_any(sweep_skb); - /* rc = -ENOMEM; */ - goto nomem; - } - - header->th.th_seg = 0x00 ; + header = skb_put_zero(sweep_skb, TH_SWEEP_LENGTH); header->th.th_ch_flag = TH_SWEEP_REQ; /* 0x0f */ - header->th.th_blk_flag = 0x00; - header->th.th_is_xid = 0x00; - header->th.th_seq_num = 0x00; header->sw.th_last_seq = ch->th_seq_num; - skb_put_data(sweep_skb, header, TH_SWEEP_LENGTH); - - kfree(header); - netif_trans_update(dev); skb_queue_tail(&ch->sweep_queue, sweep_skb); @@ -768,25 +753,17 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) ch->prof.txlen += skb->len - PDU_HEADER_LENGTH; - header = kmalloc(TH_HEADER_LENGTH, gfp_type()); - if (!header) - goto nomem_exit; + /* put the TH on the packet */ + header = skb_push(skb, TH_HEADER_LENGTH); + memset(header, 0, TH_HEADER_LENGTH); - header->th_seg = 0x00; header->th_ch_flag = TH_HAS_PDU; /* Normal data */ - header->th_blk_flag = 0x00; - header->th_is_xid = 0x00; /* Just data here */ ch->th_seq_num++; header->th_seq_num = ch->th_seq_num; CTCM_PR_DBGDATA("%s(%s) ToVTAM_th_seq= %08x\n" , __func__, dev->name, ch->th_seq_num); - /* put the TH on the packet */ - memcpy(skb_push(skb, TH_HEADER_LENGTH), header, TH_HEADER_LENGTH); - - kfree(header); - CTCM_PR_DBGDATA("%s(%s): skb len: %04x\n - pdu header and data for " "up to 32 bytes sent to vtam:\n", __func__, dev->name, skb->len); diff --git a/drivers/s390/net/ctcm_mpc.c b/drivers/s390/net/ctcm_mpc.c index 85a1a4533cbe..293d8870968c 100644 --- a/drivers/s390/net/ctcm_mpc.c +++ b/drivers/s390/net/ctcm_mpc.c @@ -655,24 +655,10 @@ static void ctcmpc_send_sweep_resp(struct channel *rch) goto done; } - header = kmalloc(sizeof(struct th_sweep), gfp_type()); - - if (!header) { - dev_kfree_skb_any(sweep_skb); - goto done; - } - - header->th.th_seg = 0x00 ; + header = skb_put_zero(sweep_skb, TH_SWEEP_LENGTH); header->th.th_ch_flag = TH_SWEEP_RESP; - header->th.th_blk_flag = 0x00; - header->th.th_is_xid = 0x00; - header->th.th_seq_num = 0x00; header->sw.th_last_seq = ch->th_seq_num; - skb_put_data(sweep_skb, header, TH_SWEEP_LENGTH); - - kfree(header); - netif_trans_update(dev); skb_queue_tail(&ch->sweep_queue, sweep_skb); From patchwork Mon Nov 30 10:09:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Wiedmann X-Patchwork-Id: 335067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8259DC83012 for ; Mon, 30 Nov 2020 10:10:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E2972084C for ; Mon, 30 Nov 2020 10:10:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ih882dcE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729018AbgK3KKw (ORCPT ); Mon, 30 Nov 2020 05:10:52 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:23728 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728577AbgK3KKs (ORCPT ); Mon, 30 Nov 2020 05:10:48 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AUA1lAw168219; Mon, 30 Nov 2020 05:09:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=oPHlPeWN+kwwB80gdj1L1jKwnCWCpPsHhppZ74X1bHU=; b=ih882dcEOXDpvzZB005mENbspgA74R4w9jNw98owq5+PQETwEVP26ueWQqhKSCvEbxXN g8noOqbf9bYBfiPWJgrS5LqzjXrejXN5ESKtNhN8SXIrEmzMQX/xZQYa4Jc9w/u3aMf9 VgMkgCTLqi96lcqe8JoU46eGViEypj8a6H6YfLys/n4RdaVJemBQs+l89iWNkaeVWg/n vudkAJcOyoSXhkVxqLqPGnTTAx59WNqt8PxJsX5ZMg88wJYVMOKyAKQCmerVVinuEqvZ 80nb0tY/a0r2z/Z+qIwArfduaEs4OBdhNmtumWHpQPjQzOUtdlVkPEGie8abd1AT5Psa Qg== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 354v98cccf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2020 05:09:58 -0500 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0AUA7bfx009800; Mon, 30 Nov 2020 10:09:57 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 353e681w3j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2020 10:09:57 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0AUA9stp57475350 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Nov 2020 10:09:54 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5086911C054; Mon, 30 Nov 2020 10:09:54 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0BA2D11C04C; Mon, 30 Nov 2020 10:09:54 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 30 Nov 2020 10:09:53 +0000 (GMT) From: Julian Wiedmann To: David Miller , Jakub Kicinski Cc: linux-netdev , linux-s390 , Heiko Carstens , Karsten Graul , Julian Wiedmann , Sebastian Andrzej Siewior Subject: [PATCH net-next 2/6] s390/ctcm: Avoid temporary allocation of struct qllc. Date: Mon, 30 Nov 2020 11:09:46 +0100 Message-Id: <20201130100950.42051-3-jwi@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201130100950.42051-1-jwi@linux.ibm.com> References: <20201130100950.42051-1-jwi@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-30_02:2020-11-30,2020-11-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 impostorscore=0 mlxscore=0 suspectscore=2 phishscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011300061 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Sebastian Andrzej Siewior The size of struct qllc is 2 byte. The memory for is allocated, initialized, used and deallocated a few lines later. It is more efficient to avoid the allocation/free dance and assign the values directly to skb's data part instead of using memcpy() for it. Avoid an allocation of struct qllc and use the resulting skb pointer instead. Signed-off-by: Sebastian Andrzej Siewior [jwi: remove a newline, reflow the commit msg] Signed-off-by: Julian Wiedmann --- drivers/s390/net/ctcm_mpc.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/s390/net/ctcm_mpc.c b/drivers/s390/net/ctcm_mpc.c index 293d8870968c..8ae49732d1d2 100644 --- a/drivers/s390/net/ctcm_mpc.c +++ b/drivers/s390/net/ctcm_mpc.c @@ -2048,7 +2048,6 @@ static void mpc_action_rcvd_xid7(fsm_instance *fsm, int event, void *arg) */ static int mpc_send_qllc_discontact(struct net_device *dev) { - __u32 new_len = 0; struct sk_buff *skb; struct qllc *qllcptr; struct ctcm_priv *priv = dev->ml_priv; @@ -2079,31 +2078,19 @@ static int mpc_send_qllc_discontact(struct net_device *dev) case MPCG_STATE_FLOWC: case MPCG_STATE_READY: grp->send_qllc_disc = 2; - new_len = sizeof(struct qllc); - qllcptr = kzalloc(new_len, gfp_type() | GFP_DMA); - if (qllcptr == NULL) { - CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR, - "%s(%s): qllcptr allocation error", - CTCM_FUNTAIL, dev->name); - return -ENOMEM; - } - - qllcptr->qllc_address = 0xcc; - qllcptr->qllc_commands = 0x03; - - skb = __dev_alloc_skb(new_len, GFP_ATOMIC); + skb = __dev_alloc_skb(sizeof(struct qllc), GFP_ATOMIC); if (skb == NULL) { CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR, "%s(%s): skb allocation error", CTCM_FUNTAIL, dev->name); priv->stats.rx_dropped++; - kfree(qllcptr); return -ENOMEM; } - skb_put_data(skb, qllcptr, new_len); - kfree(qllcptr); + qllcptr = skb_put(skb, sizeof(struct qllc)); + qllcptr->qllc_address = 0xcc; + qllcptr->qllc_commands = 0x03; if (skb_headroom(skb) < 4) { CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR, From patchwork Mon Nov 30 10:09:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Wiedmann X-Patchwork-Id: 335708 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26945C64E8A for ; Mon, 30 Nov 2020 10:11:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF0D620659 for ; Mon, 30 Nov 2020 10:11:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="oukcirtc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729094AbgK3KKz (ORCPT ); Mon, 30 Nov 2020 05:10:55 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:27876 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728577AbgK3KKz (ORCPT ); Mon, 30 Nov 2020 05:10:55 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AUA2foA091955; Mon, 30 Nov 2020 05:10:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=W3Yqk+pfBXrgKNlDkxtI4UiuvSp6l5Hl+gLwHUFcV5M=; b=oukcirtcVcJyuV8u+ueK+Sh3QFr1Uqug0Qf0CVO1ywREfrMP7R4VNwEDzacvy/G62Nu6 i1A6OwCRwQa7KNxAVj14kl3vT30Te4C1odZNswdHG0m8sGLmPUvyt7w6GciAlsqgKtRp tfyurqmzxImgt4aq6CYIPLn3OFL2IMmuDEA9iJy76p0xcNvyfK/8zvRtMPBuhwL2WYXz 9+DeznIkFNxV2CN2jgL9qxBvGmobbUHvb6E9fYTa7fFbNxPKctYmbZwzdQy1HSOhA0US qoIdVrgaLwidIr2z2sPKiUyJuBe4U2tGTqDyOWKtPxCCrm1HiWz+815a0/qPpSFtYqSP rg== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 354xkv89rq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2020 05:09:59 -0500 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0AUA7tXL013757; Mon, 30 Nov 2020 10:09:57 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 354fpd8mvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2020 10:09:57 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0AUA9sAO41484660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Nov 2020 10:09:54 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A206A11C054; Mon, 30 Nov 2020 10:09:54 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D05911C058; Mon, 30 Nov 2020 10:09:54 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 30 Nov 2020 10:09:54 +0000 (GMT) From: Julian Wiedmann To: David Miller , Jakub Kicinski Cc: linux-netdev , linux-s390 , Heiko Carstens , Karsten Graul , Julian Wiedmann , Sebastian Andrzej Siewior Subject: [PATCH net-next 3/6] s390/ctcm: Avoid temporary allocation of struct pdu. Date: Mon, 30 Nov 2020 11:09:47 +0100 Message-Id: <20201130100950.42051-4-jwi@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201130100950.42051-1-jwi@linux.ibm.com> References: <20201130100950.42051-1-jwi@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-30_02:2020-11-30,2020-11-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 mlxlogscore=999 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011300063 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Sebastian Andrzej Siewior The size of struct pdu is 8 byte. The memory is allocated, initialized, used and deallocated a few lines later. It is more efficient to avoid the allocation/free dance and assign the values directly to skb's data part instead of using memcpy() for it. Avoid an allocation of struct pdu and use the resulting skb pointer instead. Signed-off-by: Sebastian Andrzej Siewior [jwi: Fix-up the pdu_offset, adjust skb->len for the pushed length. Reflow the commit msg.] Signed-off-by: Julian Wiedmann --- drivers/s390/net/ctcm_main.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c index 9e28c63415ed..92dd3c803d23 100644 --- a/drivers/s390/net/ctcm_main.c +++ b/drivers/s390/net/ctcm_main.c @@ -665,24 +665,16 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) if ((fsm_getstate(ch->fsm) != CTC_STATE_TXIDLE) || grp->in_sweep) { spin_lock_irqsave(&ch->collect_lock, saveflags); refcount_inc(&skb->users); - p_header = kmalloc(PDU_HEADER_LENGTH, gfp_type()); - if (!p_header) { - spin_unlock_irqrestore(&ch->collect_lock, saveflags); - goto nomem_exit; - } - - p_header->pdu_offset = skb->len; + p_header = skb_push(skb, PDU_HEADER_LENGTH); + p_header->pdu_offset = skb->len - PDU_HEADER_LENGTH; p_header->pdu_proto = 0x01; - p_header->pdu_flag = 0x00; if (be16_to_cpu(skb->protocol) == ETH_P_SNAP) { - p_header->pdu_flag |= PDU_FIRST | PDU_CNTL; + p_header->pdu_flag = PDU_FIRST | PDU_CNTL; } else { - p_header->pdu_flag |= PDU_FIRST; + p_header->pdu_flag = PDU_FIRST; } p_header->pdu_seq = 0; - memcpy(skb_push(skb, PDU_HEADER_LENGTH), p_header, - PDU_HEADER_LENGTH); CTCM_PR_DEBUG("%s(%s): Put on collect_q - skb len: %04x \n" "pdu header and data for up to 32 bytes:\n", @@ -691,7 +683,6 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) skb_queue_tail(&ch->collect_queue, skb); ch->collect_len += skb->len; - kfree(p_header); spin_unlock_irqrestore(&ch->collect_lock, saveflags); goto done; @@ -721,23 +712,15 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) } } - p_header = kmalloc(PDU_HEADER_LENGTH, gfp_type()); - - if (!p_header) - goto nomem_exit; - - p_header->pdu_offset = skb->len; + p_header = skb_push(skb, PDU_HEADER_LENGTH); + p_header->pdu_offset = skb->len - PDU_HEADER_LENGTH; p_header->pdu_proto = 0x01; - p_header->pdu_flag = 0x00; p_header->pdu_seq = 0; if (be16_to_cpu(skb->protocol) == ETH_P_SNAP) { - p_header->pdu_flag |= PDU_FIRST | PDU_CNTL; + p_header->pdu_flag = PDU_FIRST | PDU_CNTL; } else { - p_header->pdu_flag |= PDU_FIRST; + p_header->pdu_flag = PDU_FIRST; } - memcpy(skb_push(skb, PDU_HEADER_LENGTH), p_header, PDU_HEADER_LENGTH); - - kfree(p_header); if (ch->collect_len > 0) { spin_lock_irqsave(&ch->collect_lock, saveflags); From patchwork Mon Nov 30 10:09:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Wiedmann X-Patchwork-Id: 335707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BAA2C71155 for ; Mon, 30 Nov 2020 10:11:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B4A520659 for ; Mon, 30 Nov 2020 10:11:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ij/ofBcp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729113AbgK3KK4 (ORCPT ); Mon, 30 Nov 2020 05:10:56 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36466 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729024AbgK3KKz (ORCPT ); Mon, 30 Nov 2020 05:10:55 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AUA2ZLH059654; Mon, 30 Nov 2020 05:10:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=3ZuFda0CcINQ/OvRog8OXaklKCPaxgdL2PGqrMylxOo=; b=ij/ofBcpSzqRPivyac8i8aD5WFyvYqq+/dpWezYFlvu3Hkh7awdfn2teFCcgvNX2Fxt4 8zj9fx+l+l6BKEqcT4AjlVGHfpyYM0ZfvOQ5z5nfhYFQMYtIZa4g/abWNo8ePHI8WIH+ Kf0zGKymDaV7/j5fm8ZIRqn1aLtkseOMfNO6MN5vUwzc+b0XXdHysFMD7TwAg0Z1QAv9 H+/KWh/0jX2DCwTAMNQSW6idQiL62I785NoucY1cgHYk2CAPI+Pjd/PEIHEi/ifTANCo v+QPoAHss1dKJc5WMqmr7HaJsGzRY1bB8dyRCEzA3J1vuGTjDhmde50Q+v6xVNuNApce IA== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 354xe2ghn0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2020 05:10:00 -0500 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0AUA7bg0009800; Mon, 30 Nov 2020 10:09:58 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 353e681w3m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2020 10:09:58 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0AUA9tPR3736144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Nov 2020 10:09:55 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0883111C04C; Mon, 30 Nov 2020 10:09:55 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE33B11C05C; Mon, 30 Nov 2020 10:09:54 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 30 Nov 2020 10:09:54 +0000 (GMT) From: Julian Wiedmann To: David Miller , Jakub Kicinski Cc: linux-netdev , linux-s390 , Heiko Carstens , Karsten Graul , Julian Wiedmann , Sebastian Andrzej Siewior Subject: [PATCH net-next 4/6] s390/ctcm: Use explicit allocation mask in ctcmpc_unpack_skb(). Date: Mon, 30 Nov 2020 11:09:48 +0100 Message-Id: <20201130100950.42051-5-jwi@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201130100950.42051-1-jwi@linux.ibm.com> References: <20201130100950.42051-1-jwi@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-30_02:2020-11-30,2020-11-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 phishscore=0 impostorscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011300061 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Sebastian Andrzej Siewior gfp_type() uses in_interrupt() to figure out the correct GFP mask. The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be separated or the context be conveyed in an argument passed by the caller, which usually knows the context. The call chain of ctcmpc_unpack_skb(): ctcmpc_bh() -> ctcmpc_unpack_skb() ctcmpc_bh() is a tasklet handler so GFP_ATOMIC is needed. Use GFP_ATOMIC as allocation type in ctcmpc_unpack_skb(). Reviewed-by: Julian Wiedmann Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Julian Wiedmann --- drivers/s390/net/ctcm_mpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/s390/net/ctcm_mpc.c b/drivers/s390/net/ctcm_mpc.c index 8ae49732d1d2..19ee91acb89d 100644 --- a/drivers/s390/net/ctcm_mpc.c +++ b/drivers/s390/net/ctcm_mpc.c @@ -1163,7 +1163,7 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) skb_pull(pskb, new_len); /* point to next PDU */ } } else { - mpcginfo = kmalloc(sizeof(struct mpcg_info), gfp_type()); + mpcginfo = kmalloc(sizeof(struct mpcg_info), GFP_ATOMIC); if (mpcginfo == NULL) goto done; From patchwork Mon Nov 30 10:09:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Wiedmann X-Patchwork-Id: 335709 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B34EC8300F for ; Mon, 30 Nov 2020 10:10:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D214B20855 for ; Mon, 30 Nov 2020 10:10:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Bf8/Ut1T" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728823AbgK3KKu (ORCPT ); Mon, 30 Nov 2020 05:10:50 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:26044 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728574AbgK3KKs (ORCPT ); Mon, 30 Nov 2020 05:10:48 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AUA1qQJ174279; Mon, 30 Nov 2020 05:10:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=E5KHcOciko7HYUDJ96CY+aopFOeqsvndAgmejfFzM08=; b=Bf8/Ut1TMgVnGmpYYVCuMjGL/A0s2lfnuXHR+ZymutPlghFblR4njfpvR9oJIc5lqigK w8RYutOb2NfsOOEVEVU01yWN4yVuGJZ8pcU3zy37syAx1CuMVrHn1KNM9a3DFtPAL1rq FeyNHF/WjhaVHa/PoJRlrr+kIyJFumXsUwKpVEeU9pp8u/IeokUcDfz58KjxUvjCiaTr joZMjl7T4VVBMQcSryqpyBNaaaImnsiVdRIuG9+bV99PbjKBa1YIgK3Y5RUU0E5CF6U2 /ZTa92t5go2lNPumbFqL1+mNE3e/D4G8P1pUVtspuBO/vyurS+9EEv1bevG/tA5KNYgL vA== Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0b-001b2d01.pphosted.com with ESMTP id 354jntevnh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2020 05:10:00 -0500 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0AUA7UQT018197; Mon, 30 Nov 2020 10:09:58 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06fra.de.ibm.com with ESMTP id 353dth8yk6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2020 10:09:58 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0AUA9tid62259502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Nov 2020 10:09:55 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 635B311C04C; Mon, 30 Nov 2020 10:09:55 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 14E2F11C054; Mon, 30 Nov 2020 10:09:55 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 30 Nov 2020 10:09:55 +0000 (GMT) From: Julian Wiedmann To: David Miller , Jakub Kicinski Cc: linux-netdev , linux-s390 , Heiko Carstens , Karsten Graul , Julian Wiedmann , Sebastian Andrzej Siewior Subject: [PATCH net-next 5/6] s390/ctcm: Use GFP_KERNEL in add_channel(). Date: Mon, 30 Nov 2020 11:09:49 +0100 Message-Id: <20201130100950.42051-6-jwi@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201130100950.42051-1-jwi@linux.ibm.com> References: <20201130100950.42051-1-jwi@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-30_02:2020-11-30,2020-11-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 mlxscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011300061 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Sebastian Andrzej Siewior gfp_type() uses in_interrupt() to figure out the correct GFP mask. The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be separated or the context be conveyed in an argument passed by the caller, which usually knows the context. The memory allocation of `ch' a few lines above is using GFP_KERNEL, also an allocation a few lines later is using GFP_KERNEL. Use GFP_KERNEL for the memory allocation. Reviewed-by: Julian Wiedmann Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Julian Wiedmann --- drivers/s390/net/ctcm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c index 92dd3c803d23..c446883de5c8 100644 --- a/drivers/s390/net/ctcm_main.c +++ b/drivers/s390/net/ctcm_main.c @@ -1321,7 +1321,7 @@ static int add_channel(struct ccw_device *cdev, enum ctcm_channel_types type, ch->protocol = priv->protocol; if (IS_MPC(priv)) { - ch->discontact_th = kzalloc(TH_HEADER_LENGTH, gfp_type()); + ch->discontact_th = kzalloc(TH_HEADER_LENGTH, GFP_KERNEL); if (ch->discontact_th == NULL) goto nomem_return; From patchwork Mon Nov 30 10:09:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Wiedmann X-Patchwork-Id: 335068 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7B80C71156 for ; Mon, 30 Nov 2020 10:10:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 904EF2084C for ; Mon, 30 Nov 2020 10:10:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Ln3Ydl5a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728717AbgK3KKt (ORCPT ); Mon, 30 Nov 2020 05:10:49 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:23486 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728557AbgK3KKs (ORCPT ); Mon, 30 Nov 2020 05:10:48 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AUA3ov3096274; Mon, 30 Nov 2020 05:10:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=f0cYuig5M/932Bj4DMnadvEMI3+9RUnKgwIk4L8H+LY=; b=Ln3Ydl5aMzUQa5e6HnEKsMeYMKNsCSBi8H96hPvGJ41KkXQHhAKcxcX3ochjPA9O4ZSZ cdsrZVfKqaBqJ1799Rtq7ixdouDKz0U68L31Sx8txXsvIBs7ttqytn3ELRLVLRz3mEij di0guNvw9GD1U2BwGHXoidFMjZcsHREuopTdP6VuKXqAiGhEGNu3ZIrgcZ6GT/6OrPXg cs5TxP6Rw8iSXMeUtmBycuGgAh+h5DomGFvcPAVqr+hHQusyGYn8abATYe5th3Jg+0aO dL9UDog8XZLVMkOy3CiDSmHX9QvW3bCbPQ8931uQ/EC7mxMNsYqUBDGTUAHpbeE//bT2 Cg== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 354wp49x5y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2020 05:10:00 -0500 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0AUA7bg1009800; Mon, 30 Nov 2020 10:09:58 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 353e681w3n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Nov 2020 10:09:58 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0AUA9tHl62259508 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Nov 2020 10:09:55 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B424111C058; Mon, 30 Nov 2020 10:09:55 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FA1811C050; Mon, 30 Nov 2020 10:09:55 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 30 Nov 2020 10:09:55 +0000 (GMT) From: Julian Wiedmann To: David Miller , Jakub Kicinski Cc: linux-netdev , linux-s390 , Heiko Carstens , Karsten Graul , Julian Wiedmann , Sebastian Andrzej Siewior Subject: [PATCH net-next 6/6] s390/ctcm: Use GFP_ATOMIC in ctcmpc_tx(). Date: Mon, 30 Nov 2020 11:09:50 +0100 Message-Id: <20201130100950.42051-7-jwi@linux.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201130100950.42051-1-jwi@linux.ibm.com> References: <20201130100950.42051-1-jwi@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-30_02:2020-11-30,2020-11-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 impostorscore=0 phishscore=0 mlxscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011300063 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Sebastian Andrzej Siewior gfp_type() uses in_interrupt() to figure out the correct GFP mask. The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be separated or the context be conveyed in an argument passed by the caller, which usually knows the context. ctcmpc_tx() is used as net_device_ops::ndo_start_xmit. This callback is invoked with disabled bottom halves. Use GFP_ATOMIC for memory allocation in ctcmpc_tx(). Remove gfp_type() since the last user is gone. Reviewed-by: Julian Wiedmann Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Julian Wiedmann --- drivers/s390/net/ctcm_main.c | 2 +- drivers/s390/net/ctcm_main.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c index c446883de5c8..fd705429708e 100644 --- a/drivers/s390/net/ctcm_main.c +++ b/drivers/s390/net/ctcm_main.c @@ -903,7 +903,7 @@ static int ctcmpc_tx(struct sk_buff *skb, struct net_device *dev) CTCM_D3_DUMP((char *)skb->data, min_t(int, 32, skb->len)); len = skb->len + TH_HEADER_LENGTH + PDU_HEADER_LENGTH; - newskb = __dev_alloc_skb(len, gfp_type() | GFP_DMA); + newskb = __dev_alloc_skb(len, GFP_ATOMIC | GFP_DMA); if (!newskb) { CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_ERROR, diff --git a/drivers/s390/net/ctcm_main.h b/drivers/s390/net/ctcm_main.h index 16bdf23ee02b..90bd7b3f80c3 100644 --- a/drivers/s390/net/ctcm_main.h +++ b/drivers/s390/net/ctcm_main.h @@ -298,11 +298,6 @@ struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv); /* test if struct ctcm_priv of struct net_device has MPC protocol setting */ #define IS_MPCDEV(dev) IS_MPC((struct ctcm_priv *)dev->ml_priv) -static inline gfp_t gfp_type(void) -{ - return in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; -} - /* * Definition of our link level header. */